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

tests: fix tests that broke when using a symlinked /tmp

This commit is contained in:
Arcterus 2016-01-10 02:47:57 -08:00
parent d9ad0b185a
commit 49d0815588
4 changed files with 15 additions and 19 deletions

View file

@ -53,16 +53,6 @@ pub struct CmdResult {
pub stderr: String, 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) { pub fn log_info<T: AsRef<str>, U: AsRef<str>>(msg: T, par: U) {
println!("{}: {}", msg.as_ref(), par.as_ref()); println!("{}: {}", msg.as_ref(), par.as_ref());
} }
@ -215,10 +205,16 @@ impl AtPath {
Err(_) => {} Err(_) => {}
} }
} }
pub fn root_dir(&self) -> String { pub fn root_dir(&self) -> String {
log_info("current_directory", ""); log_info("current_directory", "");
self.subdir.to_str().unwrap().to_owned() self.subdir.to_str().unwrap().to_owned()
} }
pub fn root_dir_resolved(&self) -> String {
log_info("current_directory_resolved", "");
self.subdir.canonicalize().unwrap().to_str().unwrap().to_owned()
}
} }
pub struct TestSet { pub struct TestSet {

View file

@ -11,6 +11,6 @@ fn test_default() {
let (at, mut ucmd) = testing(UTIL_NAME); let (at, mut ucmd) = testing(UTIL_NAME);
let out = ucmd.run().stdout; let out = ucmd.run().stdout;
let expected = at.root_dir(); let expected = at.root_dir_resolved();
assert_eq!(trim_private(out.trim_right()), expected); assert_eq!(out.trim_right(), expected);
} }

View file

@ -16,7 +16,7 @@ fn test_canonicalize() {
.run() .run()
.stdout; .stdout;
assert_eq!(trim_private(out.trim_right()), at.root_dir()); assert_eq!(out.trim_right(), at.root_dir_resolved());
} }
#[test] #[test]
@ -27,13 +27,13 @@ fn test_canonicalize_existing() {
.run() .run()
.stdout; .stdout;
assert_eq!(trim_private(out.trim_right()), at.root_dir()); assert_eq!(out.trim_right(), at.root_dir_resolved());
} }
#[test] #[test]
fn test_canonicalize_missing() { fn test_canonicalize_missing() {
let (at, mut ucmd) = testing(UTIL_NAME); let (at, mut ucmd) = testing(UTIL_NAME);
let mut expected = at.root_dir(); let mut expected = at.root_dir_resolved();
expected.push_str("/"); expected.push_str("/");
expected.push_str(GIBBERISH); expected.push_str(GIBBERISH);
@ -42,7 +42,7 @@ fn test_canonicalize_missing() {
.run() .run()
.stdout; .stdout;
assert_eq!(trim_private(out.trim_right()), expected); assert_eq!(out.trim_right(), expected);
} }
#[test] #[test]
@ -56,7 +56,7 @@ fn test_long_redirection_to_current_dir() {
.run() .run()
.stdout; .stdout;
assert_eq!(trim_private(&out), at.root_dir()); assert_eq!(out, at.root_dir_resolved());
} }
#[test] #[test]

View file

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