-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try to make symlink testdata more robust
- Loading branch information
1 parent
417afe6
commit ac38795
Showing
2 changed files
with
23 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,7 @@ | ||
use std::path::Path; | ||
|
||
fn read_through_symlink() -> String { | ||
pub 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!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use std::fs::{read_link, read_to_string}; | ||
use std::path::Path; | ||
|
||
use cargo_mutants_testdata_symlink::read_through_symlink; | ||
|
||
#[test] | ||
fn read_through_symlink_test() { | ||
assert_eq!(read_through_symlink().trim(), "Hello, world!"); | ||
} | ||
|
||
/// This should fail from the baseline test if the symlink is somehow | ||
/// missing. | ||
#[test] | ||
fn symlink_testdata_exists() { | ||
let target = Path::new("testdata/target"); | ||
let symlink = Path::new("testdata/symlink"); | ||
assert!(symlink.is_symlink()); | ||
assert!(target.is_file()); | ||
assert_eq!(read_link(&symlink).unwrap(), Path::new("target")); | ||
assert_eq!(read_to_string(&target).unwrap().trim(), "Hello, world!"); | ||
assert_eq!(read_to_string(&symlink).unwrap().trim(), "Hello, world!"); | ||
} |