Skip to content

Commit

Permalink
Test copying symlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
sourcefrog committed Nov 25, 2023
1 parent 82e77d0 commit dcc237d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions testdata/symlink/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "cargo-mutants-testdata-symlink"
version = "0.0.0"
edition = "2021"
publish = false

[lib]
doctest = false
3 changes: 3 additions & 0 deletions testdata/symlink/README.md
Original file line number Diff line number Diff line change
@@ -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.
15 changes: 15 additions & 0 deletions testdata/symlink/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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!");
}
}
1 change: 1 addition & 0 deletions testdata/symlink/testdata/symlink
1 change: 1 addition & 0 deletions testdata/symlink/testdata/target
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, world!
12 changes: 12 additions & 0 deletions tests/cli/build_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit dcc237d

Please sign in to comment.