1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

tests: fix tests that were failing on OS X

This commit is contained in:
Arcterus 2016-01-10 00:09:05 -08:00
parent 27c77db122
commit d9ad0b185a
6 changed files with 20 additions and 13 deletions

View file

@ -14,6 +14,3 @@ script:
- ./.travis_fixup.sh
- cargo build
- cargo test --no-fail-fast
matrix:
allow_failures:
- os: osx

View file

@ -300,12 +300,12 @@ fn parse_change(mode: &str, fperm: libc::mode_t, file: &Path) -> (libc::mode_t,
fn change_file(fperm: libc::mode_t, mode: libc::mode_t, file: &Path, path: &CString, verbose: bool, changes: bool, quiet: bool) -> Result<(), i32> {
if fperm == mode {
if verbose && !changes {
show_info!("mode of \"{}\" retained as {:o}", file.display(), fperm);
show_info!("mode of '{}' retained as {:o}", file.display(), fperm);
}
Ok(())
} else if unsafe { libc::chmod(path.as_ptr(), mode) } == 0 {
if verbose || changes {
show_info!("mode of \"{}\" changed from {:o} to {:o}", file.display(), fperm, mode);
show_info!("mode of '{}' changed from {:o} to {:o}", file.display(), fperm, mode);
}
Ok(())
} else {
@ -313,7 +313,7 @@ fn change_file(fperm: libc::mode_t, mode: libc::mode_t, file: &Path, path: &CStr
show_error!("{}", io::Error::last_os_error());
}
if verbose {
show_info!("failed to change mode of file \"{}\" from {:o} to {:o}", file.display(), fperm, mode);
show_info!("failed to change mode of file '{}' from {:o} to {:o}", file.display(), fperm, mode);
}
return Err(1);
}

View file

@ -53,6 +53,16 @@ pub struct CmdResult {
pub stderr: String,
}
#[cfg(target_os = "macos")]
pub fn trim_private(input: &str) -> &str {
input.trim_left_matches("/private")
}
#[cfg(not(target_os = "macos"))]
pub fn trim_private(input: &str) -> &str {
input
}
pub fn log_info<T: AsRef<str>, U: AsRef<str>>(msg: T, par: U) {
println!("{}: {}", msg.as_ref(), par.as_ref());
}

View file

@ -12,5 +12,5 @@ fn test_default() {
let out = ucmd.run().stdout;
let expected = at.root_dir();
assert_eq!(out.trim_right(), expected);
assert_eq!(trim_private(out.trim_right()), expected);
}

View file

@ -16,7 +16,7 @@ fn test_canonicalize() {
.run()
.stdout;
assert_eq!(out.trim_right(), at.root_dir());
assert_eq!(trim_private(out.trim_right()), at.root_dir());
}
#[test]
@ -27,7 +27,7 @@ fn test_canonicalize_existing() {
.run()
.stdout;
assert_eq!(out.trim_right(), at.root_dir());
assert_eq!(trim_private(out.trim_right()), at.root_dir());
}
#[test]
@ -42,7 +42,7 @@ fn test_canonicalize_missing() {
.run()
.stdout;
assert_eq!(out.trim_right(), expected);
assert_eq!(trim_private(out.trim_right()), expected);
}
#[test]
@ -56,7 +56,7 @@ fn test_long_redirection_to_current_dir() {
.run()
.stdout;
assert_eq!(out, at.root_dir());
assert_eq!(trim_private(&out), at.root_dir());
}
#[test]

View file

@ -10,7 +10,7 @@ fn test_current_directory() {
let (at, mut ucmd) = testing(UTIL_NAME);
let out = ucmd.arg(".").run().stdout;
assert_eq!(out.trim_right(), at.root_dir());
assert_eq!(trim_private(out.trim_right()), at.root_dir());
}
#[test]
@ -20,7 +20,7 @@ fn test_long_redirection_to_current_dir() {
let dir = repeat_str("./", 128);
let out = ucmd.arg(dir).run().stdout;
assert_eq!(out.trim_right(), at.root_dir());
assert_eq!(trim_private(out.trim_right()), at.root_dir());
}
#[test]