Skip to content

Commit

Permalink
Remove extra testdata/tree directory (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog authored Nov 25, 2023
2 parents fff4987 + 6373cc7 commit c9f2210
Show file tree
Hide file tree
Showing 143 changed files with 159 additions and 161 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ When the tests run, `cargo test` runs a test suite binary from `target`, which t

As a result, attaching a debugger to the test binary will let you see the code that launches the subprocess and that inspects the output, but it won't let you step through cargo-mutants itself, which is probably the most interesting part.

Probably the easiest path is to just make note of the command run by the test, and then run that command yourself, under a debugger, outside of the test suite. For example, `./target/debug/cargo-mutants -d ./testdata/tree/factorial --list`.
Probably the easiest path is to just make note of the command run by the test, and then run that command yourself, under a debugger, outside of the test suite. For example, `./target/debug/cargo-mutants -d ./testdata/factorial --list`.

You may wish to turn off the timeouts with `-t 0`.

Expand Down
62 changes: 31 additions & 31 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,35 +98,35 @@ resolver = "2"
# so that support for testing workspaces does not try to test the whole
# cargo-mutants tree.
exclude = [
"testdata/tree/already_failing_tests",
"testdata/tree/already_hangs",
"testdata/tree/cdylib",
"testdata/tree/cfg_attr_mutants_skip",
"testdata/tree/cfg_attr_test_skip",
"testdata/tree/dependency",
"testdata/tree/diff0",
"testdata/tree/diff1",
"testdata/tree/error_value",
"testdata/tree/everything_skipped",
"testdata/tree/factorial",
"testdata/tree/fails_without_feature",
"testdata/tree/hang_avoided_by_attr/",
"testdata/tree/hang_when_mutated",
"testdata/tree/insta",
"testdata/tree/integration_tests",
"testdata/tree/missing_test",
"testdata/tree/mut_ref",
"testdata/tree/never_type",
"testdata/tree/override_dependency",
"testdata/tree/package-fails/",
"testdata/tree/patch_dependency",
"testdata/tree/relative_dependency",
"testdata/tree/replace_dependency",
"testdata/tree/small_well_tested",
"testdata/tree/strict_warnings",
"testdata/tree/struct_with_no_default",
"testdata/tree/unapply",
"testdata/tree/unsafe",
"testdata/tree/well_tested",
"testdata/tree/with_child_directories",
"testdata/already_failing_tests",
"testdata/already_hangs",
"testdata/cdylib",
"testdata/cfg_attr_mutants_skip",
"testdata/cfg_attr_test_skip",
"testdata/dependency",
"testdata/diff0",
"testdata/diff1",
"testdata/error_value",
"testdata/everything_skipped",
"testdata/factorial",
"testdata/fails_without_feature",
"testdata/hang_avoided_by_attr/",
"testdata/hang_when_mutated",
"testdata/insta",
"testdata/integration_tests",
"testdata/missing_test",
"testdata/mut_ref",
"testdata/never_type",
"testdata/override_dependency",
"testdata/package-fails/",
"testdata/patch_dependency",
"testdata/relative_dependency",
"testdata/replace_dependency",
"testdata/small_well_tested",
"testdata/strict_warnings",
"testdata/struct_with_no_default",
"testdata/unapply",
"testdata/unsafe",
"testdata/well_tested",
"testdata/with_child_directories",
]
2 changes: 1 addition & 1 deletion DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Cargo-mutants is primarily tested on its public interface, which is the command

### `testdata` trees

The primary means of testing is Rust source trees under `testdata/tree`: you can copy an existing tree and modify it to show the new behavior that you want to test.
The primary means of testing is Rust source trees under `testdata`: you can copy an existing tree and modify it to show the new behavior that you want to test.

A selection of test trees are available for testing different scenarios. If there is an existing suitable tree, please use it. If you need to test a situation that is not covered yet, please add a new tree.

Expand Down
2 changes: 1 addition & 1 deletion src/build_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ mod test {
#[test]
fn build_dir_debug_form() {
let options = Options::default();
let workspace = Workspace::open("testdata/tree/factorial").unwrap();
let workspace = Workspace::open("testdata/factorial").unwrap();
let build_dir = BuildDir::new(&workspace.dir, &options, &Console::new()).unwrap();
let debug_form = format!("{build_dir:?}");
assert!(
Expand Down
4 changes: 2 additions & 2 deletions src/in_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ index eb42779..a0091b7 100644

#[test]
fn reconstruct_partial_new_file() {
let old = read_to_string("testdata/tree/diff0/src/lib.rs").unwrap();
let new = read_to_string("testdata/tree/diff1/src/lib.rs").unwrap();
let old = read_to_string("testdata/diff0/src/lib.rs").unwrap();
let new = read_to_string("testdata/diff1/src/lib.rs").unwrap();
let diff = make_diff(&old, &new);
let patch = Patch::from_single(&diff).unwrap();
let reconstructed = partial_new_file(&patch);
Expand Down
6 changes: 3 additions & 3 deletions src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mod test {

#[test]
fn fix_path_absolute_unchanged() {
let dependency_abspath = Utf8Path::new("testdata/tree/dependency")
let dependency_abspath = Utf8Path::new("testdata/dependency")
.canonicalize_utf8()
.unwrap();
assert_eq!(
Expand All @@ -181,13 +181,13 @@ mod test {
fn fix_path_relative() {
let fixed_path: Utf8PathBuf = super::fix_path(
"../dependency",
Utf8Path::new("testdata/tree/relative_dependency"),
Utf8Path::new("testdata/relative_dependency"),
)
.expect("path was adjusted")
.into();
assert_eq!(
&fixed_path,
Utf8Path::new("testdata/tree/relative_dependency/../dependency"),
Utf8Path::new("testdata/relative_dependency/../dependency"),
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/mutate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ mod test {

#[test]
fn discover_factorial_mutants() {
let tree_path = Utf8Path::new("testdata/tree/factorial");
let tree_path = Utf8Path::new("testdata/factorial");
let workspace = Workspace::open(tree_path).unwrap();
let options = Options::default();
let mutants = workspace
Expand Down Expand Up @@ -262,7 +262,7 @@ mod test {

#[test]
fn filter_by_attributes() {
let mutants = Workspace::open(Utf8Path::new("testdata/tree/hang_avoided_by_attr"))
let mutants = Workspace::open(Utf8Path::new("testdata/hang_avoided_by_attr"))
.unwrap()
.mutants(&PackageFilter::All, &Options::default(), &Console::new())
.unwrap();
Expand All @@ -275,7 +275,7 @@ mod test {

#[test]
fn mutate_factorial() -> Result<()> {
let tree_path = Utf8Path::new("testdata/tree/factorial");
let tree_path = Utf8Path::new("testdata/factorial");
let mutants = Workspace::open(tree_path)?.mutants(
&PackageFilter::All,
&Options::default(),
Expand Down
20 changes: 9 additions & 11 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ mod test {

#[test]
fn open_subdirectory_of_crate_opens_the_crate() {
let workspace = Workspace::open("testdata/tree/factorial/src")
.expect("open source tree from subdirectory");
let workspace =
Workspace::open("testdata/factorial/src").expect("open source tree from subdirectory");
let root = &workspace.dir;
assert!(root.is_dir());
assert!(root.join("Cargo.toml").is_file());
Expand All @@ -328,16 +328,15 @@ mod test {

#[test]
fn find_root_from_subdirectory_of_workspace_finds_the_workspace_root() {
let root = Workspace::open("testdata/tree/workspace/main")
let root = Workspace::open("testdata/workspace/main")
.expect("Find root from within workspace/main")
.dir;
assert_eq!(root.file_name(), Some("workspace"), "Wrong root: {root:?}");
}

#[test]
fn find_top_source_files_from_subdirectory_of_workspace() {
let workspace =
Workspace::open("testdata/tree/workspace/main").expect("Find workspace root");
let workspace = Workspace::open("testdata/workspace/main").expect("Find workspace root");
assert_eq!(
workspace
.packages(&PackageFilter::All)
Expand All @@ -361,7 +360,7 @@ mod test {

#[test]
fn package_filter_all_from_subdir_gets_everything() {
let subdir_path = Utf8Path::new("testdata/tree/workspace/main");
let subdir_path = Utf8Path::new("testdata/workspace/main");
let workspace = Workspace::open(subdir_path).expect("Find workspace root");
let packages = workspace.packages(&PackageFilter::All).unwrap();
assert_eq!(
Expand All @@ -372,7 +371,7 @@ mod test {

#[test]
fn auto_packages_in_workspace_subdir_finds_single_package() {
let subdir_path = Utf8Path::new("testdata/tree/workspace/main");
let subdir_path = Utf8Path::new("testdata/workspace/main");
let workspace = Workspace::open(subdir_path).expect("Find workspace root");
let packages = workspace
.packages(&PackageFilter::Auto(subdir_path.to_owned()))
Expand All @@ -382,7 +381,7 @@ mod test {

#[test]
fn auto_packages_in_virtual_workspace_gets_everything() {
let path = Utf8Path::new("testdata/tree/workspace");
let path = Utf8Path::new("testdata/workspace");
let workspace = Workspace::open(path).expect("Find workspace root");
let packages = workspace
.packages(&PackageFilter::Auto(path.to_owned()))
Expand All @@ -395,8 +394,7 @@ mod test {

#[test]
fn filter_by_single_package() {
let workspace =
Workspace::open("testdata/tree/workspace/main").expect("Find workspace root");
let workspace = Workspace::open("testdata/workspace/main").expect("Find workspace root");
let root_dir = &workspace.dir;
assert_eq!(
root_dir.file_name(),
Expand Down Expand Up @@ -426,7 +424,7 @@ mod test {

#[test]
fn filter_by_multiple_packages() {
let workspace = Workspace::open("testdata/tree/workspace/main").unwrap();
let workspace = Workspace::open("testdata/workspace/main").unwrap();
assert_eq!(
workspace.dir.file_name(),
Some("workspace"),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ mutants` uses the corresponding `cargo` and `rustc` when building candidates.

For example this should fail:

cargo +stable mutants -d ./testdata/tree/nightly_only/
cargo +stable mutants -d ./testdata/nightly_only/

and this should succeed:

cargo +nightly mutants -d ./testdata/tree/nightly_only/
cargo +nightly mutants -d ./testdata/nightly_only/

This isn't covered by an integration test because there's no guarantee the user
has both toolchains installed...
File renamed without changes.
1 change: 1 addition & 0 deletions testdata/override_dependency/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
paths = ["../../mutants_attrs"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ publish = false
mutants = { version = "0" }

[patch.crates-io]
"mutants" = { path = "../../../mutants_attrs" }
"mutants" = { path = "../../mutants_attrs" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ publish = false
mutants = { version = "0" }

[replace]
"mutants:0.0.3" = { path = "../../../mutants_attrs" }
"mutants:0.0.3" = { path = "../../mutants_attrs" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion testdata/tree/override_dependency/.cargo/config.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions tests/cli/in_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ fn diff_trees_well_tested() {

#[test]
fn list_mutants_changed_in_diff1() {
let src0 = read_to_string("testdata/tree/diff0/src/lib.rs").unwrap();
let src1 = read_to_string("testdata/tree/diff1/src/lib.rs").unwrap();
let src0 = read_to_string("testdata/diff0/src/lib.rs").unwrap();
let src1 = read_to_string("testdata/diff1/src/lib.rs").unwrap();
let diff = TextDiff::from_lines(&src0, &src1)
.unified_diff()
.context_radius(2)
Expand Down Expand Up @@ -70,8 +70,8 @@ fn list_mutants_changed_in_diff1() {
/// If the text in the diff doesn't look like the tree then error out.
#[test]
fn mismatched_diff_causes_error() {
let src0 = read_to_string("testdata/tree/diff0/src/lib.rs").unwrap();
let src1 = read_to_string("testdata/tree/diff1/src/lib.rs").unwrap();
let src0 = read_to_string("testdata/diff0/src/lib.rs").unwrap();
let src1 = read_to_string("testdata/diff1/src/lib.rs").unwrap();
let diff = TextDiff::from_lines(&src0, &src1)
.unified_diff()
.context_radius(2)
Expand Down
Loading

0 comments on commit c9f2210

Please sign in to comment.