Skip to content

Commit

Permalink
Auto merge of #11745 - Muscraft:cleanup-tests, r=epage
Browse files Browse the repository at this point in the history
Cleanup tests

When working on #11738 I noticed a few tests that needed to be cleaned up. It [was suggested](#11738 (comment)) to split the test changes into their own PR.

- `bad_config::bad1`
  - This was trying to match `config` which would get matched in the wrong place due to the test name having `config` in it
  - Fixed by making the match `/config`
- `build_script::panic_abort_with_build_scripts`
  - This test was failing as it was making sure `panic` was not in the output. After this change, it could match the test name and fail.
  - To fix this I updated it to look at `panic=abort` which appears to be what it was originally looking for (#5711). `@ehuss` please let me know if I misread what the test was testing.
- `cargo_command::cargo_subcommand_args`
  - This test had `#[test]` above `#[cargo_test]` which caused it to throw an error removing it fixed the issue

During this time I also ran into issues with `cargo_remove` tests being named `fn case()` which is different from how tests are normally named. I talked with `@epage` and it was decided that `fn case()` should probably be used for all `snapbox` tests since the unique test name is already the folder name. I went ahead and renamed all tests within `cargo_add/` and `init/` to match this style.

This PR should be reviewed commit by commit.
  • Loading branch information
bors committed Feb 21, 2023
2 parents 6e66ee8 + 822b257 commit d1d16f2
Show file tree
Hide file tree
Showing 152 changed files with 151 additions and 152 deletions.
2 changes: 1 addition & 1 deletion src/doc/contrib/src/tests/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ use cargo_test_support::Project;
use cargo_test_support::curr_dir;
#[cargo_test]
fn <name>() {
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/bad_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn bad1() {
.with_stderr(
"\
[ERROR] expected table for configuration key `target.nonexistent-target`, \
but found string in [..]config
but found string in [..]/config
",
)
.run();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3707,7 +3707,7 @@ fn panic_abort_with_build_scripts() {
p.root().join("target").rm_rf();

p.cargo("test --release -v")
.with_stderr_does_not_contain("[..]panic[..]")
.with_stderr_does_not_contain("[..]panic=abort[..]")
.run();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/add_basic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn add_basic() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/add_multiple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn add_multiple() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn add_normalized_name_external() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn build() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo_test_support::Project;
use crate::cargo_add::init_alt_registry;

#[cargo_test]
fn build_prefer_existing_version() {
fn case() {
init_alt_registry();
let project =
Project::from_template("tests/testsuite/cargo_add/build_prefer_existing_version/in");
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/change_rename_target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn change_rename_target() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/default_features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn default_features() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn deprecated_default_features() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/deprecated_section/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn deprecated_section() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/detect_workspace_inherit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn detect_workspace_inherit() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn detect_workspace_inherit_features() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn detect_workspace_inherit_optional() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn dev() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/dev_build_conflict/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn dev_build_conflict() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn dev_prefer_existing_version() {
fn case() {
init_alt_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/dry_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn dry_run() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/features_empty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_empty() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_multiple_occurrences() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/features_preserve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_preserve() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/features_spaced_values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_spaced_values() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/features_unknown/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_unknown() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn features_unknown_no_features() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_branch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_branch() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_conflicts_namever/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_conflicts_namever() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_dev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_dev() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_inferred_name/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_inferred_name() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_inferred_name_multiple() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_multiple_names/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_multiple_names() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_normalized_name/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_normalized_name() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_alt_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_registry() {
fn case() {
init_alt_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_rev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_rev() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/git_tag/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn git_tag() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/infer_prerelease/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn infer_prerelease() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/invalid_arg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_arg() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/invalid_git_external/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_git_external() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/cargo_add/invalid_git_name/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::cargo_add::init_registry;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_git_name() {
fn case() {
init_registry();
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo_test_support::Project;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_key_inherit_dependency() {
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo_test_support::Project;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_key_overwrite_inherit_dependency() {
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cargo_test_support::Project;
use cargo_test_support::curr_dir;

#[cargo_test]
fn invalid_key_rename_inherit_dependency() {
fn case() {
let project = Project::from_template(curr_dir!().join("in"));
let project_root = project.root();
let cwd = &project_root;
Expand Down
Loading

0 comments on commit d1d16f2

Please sign in to comment.