diff --git a/Cargo.toml b/Cargo.toml index e75fbc63..36533257 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,6 +124,7 @@ exclude = [ "testdata/small_well_tested", "testdata/strict_warnings", "testdata/struct_with_no_default", + "testdata/symlink", "testdata/unapply", "testdata/unsafe", "testdata/well_tested", diff --git a/testdata/symlink/Cargo.toml b/testdata/symlink/Cargo.toml new file mode 100644 index 00000000..cd7e64df --- /dev/null +++ b/testdata/symlink/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "cargo-mutants-testdata-symlink" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +doctest = false diff --git a/testdata/symlink/README.md b/testdata/symlink/README.md new file mode 100644 index 00000000..1a34d4fc --- /dev/null +++ b/testdata/symlink/README.md @@ -0,0 +1,3 @@ +# testdata/symlink + +A source tree that contains a symlink, committed to git. The symlink must exist for the tests to pass. This is used to test that cargo-mutants copies the symlinks correctly, especially on Windows. diff --git a/testdata/symlink/src/lib.rs b/testdata/symlink/src/lib.rs new file mode 100644 index 00000000..7129f12d --- /dev/null +++ b/testdata/symlink/src/lib.rs @@ -0,0 +1,15 @@ +use std::path::Path; + +fn read_through_symlink() -> String { + let path = Path::new("testdata/symlink"); + assert!(path.is_symlink()); + std::fs::read_to_string(path).unwrap() +} + +#[cfg(test)] +mod test { + #[test] + fn read_through_symlink_test() { + assert_eq!(super::read_through_symlink().trim(), "Hello, world!"); + } +} diff --git a/testdata/symlink/testdata/symlink b/testdata/symlink/testdata/symlink new file mode 120000 index 00000000..1de56593 --- /dev/null +++ b/testdata/symlink/testdata/symlink @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/testdata/symlink/testdata/target b/testdata/symlink/testdata/target new file mode 100644 index 00000000..5dd01c17 --- /dev/null +++ b/testdata/symlink/testdata/target @@ -0,0 +1 @@ +Hello, world! \ No newline at end of file diff --git a/tests/cli/build_dir.rs b/tests/cli/build_dir.rs index 8962912c..172f89b9 100644 --- a/tests/cli/build_dir.rs +++ b/tests/cli/build_dir.rs @@ -30,3 +30,15 @@ fn gitignore_can_be_turned_off() { .assert() .success(); } + +/// A tree containing a symlink that must exist for the tests to pass works properly. +/// +/// This runs in-place to avoid any complications from copying the testdata. +#[test] +fn tree_with_symlink() { + run() + .args(["mutants", "-d"]) + .arg("testdata/symlink") + .assert() + .success(); +}