-
-
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.
- Loading branch information
Showing
8 changed files
with
244 additions
and
15 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
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,7 +1,10 @@ | ||
[package] | ||
name = "cargo-mutants-testdata-missing-test" | ||
version = "0.0.0" | ||
edition = "2018" | ||
edition = "2021" | ||
authors = ["Martin Pool"] | ||
publish = false | ||
resolver = "2" | ||
|
||
[dependencies] | ||
tempfile = "3.4" |
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,8 +1,19 @@ | ||
fn is_symlink(unix_mode: u32) -> bool { | ||
unix_mode & 0o140000 != 0 | ||
pub fn is_symlink(unix_permissions: u32) -> bool { | ||
unix_permissions & 0o140000 != 0 | ||
} | ||
|
||
#[test] | ||
fn test_symlink() { | ||
fn test_symlink_from_known_unix_permissions() { | ||
assert!(is_symlink(0o147777)); | ||
} | ||
|
||
#[cfg(unix)] | ||
#[test] | ||
fn test_symlink_on_real_symlink_permissions() { | ||
use std::os::unix::fs::PermissionsExt; | ||
let td = tempfile::TempDir::new().unwrap(); | ||
let p = td.path().join("link"); | ||
std::os::unix::fs::symlink("target", &p).unwrap(); | ||
let meta = std::fs::symlink_metadata(&p).unwrap(); | ||
assert!(is_symlink(meta.permissions().mode())); | ||
} |
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,10 @@ | ||
[package] | ||
name = "cargo-mutants-testdata-missing-test-fixed" | ||
version = "0.0.0" | ||
edition = "2021" | ||
authors = ["Martin Pool"] | ||
publish = false | ||
resolver = "2" | ||
|
||
[dependencies] | ||
tempfile = "3.4" |
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 @@ | ||
A fixed and better-tested version of the code from `missing_test`. |
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,32 @@ | ||
pub fn is_symlink(unix_permissions: u32) -> bool { | ||
unix_permissions & 0o170_000 == 0o120_000 | ||
} | ||
|
||
#[test] | ||
fn test_symlink_from_known_unix_permissions() { | ||
assert!(is_symlink(0o120777)); | ||
} | ||
|
||
#[cfg(unix)] | ||
#[test] | ||
fn test_symlink_on_real_symlink_permissions() { | ||
use std::fs::symlink_metadata; | ||
use std::os::unix::fs::PermissionsExt; | ||
|
||
let td = tempfile::TempDir::new().unwrap(); | ||
|
||
let p = td.path().join("link"); | ||
std::os::unix::fs::symlink("target", &p).unwrap(); | ||
let meta = symlink_metadata(&p).unwrap(); | ||
assert!(is_symlink(meta.permissions().mode())); | ||
|
||
assert!(!is_symlink( | ||
symlink_metadata(td.path()).unwrap().permissions().mode() | ||
)); | ||
|
||
let file_path = td.path().join("file"); | ||
std::fs::File::create(&file_path).unwrap(); | ||
assert!(!is_symlink( | ||
symlink_metadata(&file_path).unwrap().permissions().mode() | ||
)); | ||
} |
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
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