mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
tests ~ refactor real{link,path} tests for easier diagnosis of failures
This commit is contained in:
parent
6adddcf9e9
commit
3ec47ff717
2 changed files with 40 additions and 27 deletions
|
@ -6,29 +6,31 @@ static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
||||||
#[test]
|
#[test]
|
||||||
fn test_canonicalize() {
|
fn test_canonicalize() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.arg("-f")
|
let actual = ucmd.arg("-f").arg(".").run().stdout;
|
||||||
.arg(".")
|
let expect = at.root_dir_resolved() + "\n";
|
||||||
.run()
|
println!("actual: {:?}", actual);
|
||||||
.stdout_is(at.root_dir_resolved() + "\n");
|
println!("expect: {:?}", expect);
|
||||||
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_canonicalize_existing() {
|
fn test_canonicalize_existing() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.arg("-e")
|
let actual = ucmd.arg("-e").arg(".").run().stdout;
|
||||||
.arg(".")
|
let expect = at.root_dir_resolved() + "\n";
|
||||||
.run()
|
println!("actual: {:?}", actual);
|
||||||
.stdout_is(at.root_dir_resolved() + "\n");
|
println!("expect: {:?}", expect);
|
||||||
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_canonicalize_missing() {
|
fn test_canonicalize_missing() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
let expected = path_concat!(at.root_dir_resolved(), GIBBERISH);
|
let actual = ucmd.arg("-m").arg(GIBBERISH).run().stdout;
|
||||||
ucmd.arg("-m")
|
let expect = path_concat!(at.root_dir_resolved(), GIBBERISH) + "\n";
|
||||||
.arg(GIBBERISH)
|
println!("actual: {:?}", actual);
|
||||||
.run()
|
println!("expect: {:?}", expect);
|
||||||
.stdout_is(expected + "\n");
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -36,21 +38,20 @@ fn test_long_redirection_to_current_dir() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
// Create a 256-character path to current directory
|
// Create a 256-character path to current directory
|
||||||
let dir = path_concat!(".", ..128);
|
let dir = path_concat!(".", ..128);
|
||||||
ucmd.arg("-n")
|
let actual = ucmd.arg("-n").arg("-m").arg(dir).run().stdout;
|
||||||
.arg("-m")
|
let expect = at.root_dir_resolved();
|
||||||
.arg(dir)
|
println!("actual: {:?}", actual);
|
||||||
.run()
|
println!("expect: {:?}", expect);
|
||||||
.stdout_is(at.root_dir_resolved());
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_long_redirection_to_root() {
|
fn test_long_redirection_to_root() {
|
||||||
// Create a 255-character path to root
|
// Create a 255-character path to root
|
||||||
let dir = path_concat!("..", ..85);
|
let dir = path_concat!("..", ..85);
|
||||||
new_ucmd!()
|
let actual = new_ucmd!().arg("-n").arg("-m").arg(dir).run().stdout;
|
||||||
.arg("-n")
|
let expect = get_root_path();
|
||||||
.arg("-m")
|
println!("actual: {:?}", actual);
|
||||||
.arg(dir)
|
println!("expect: {:?}", expect);
|
||||||
.run()
|
assert_eq!(actual, expect);
|
||||||
.stdout_is(get_root_path());
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,11 @@ use common::util::*;
|
||||||
#[test]
|
#[test]
|
||||||
fn test_current_directory() {
|
fn test_current_directory() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.arg(".").run().stdout_is(at.root_dir_resolved() + "\n");
|
let actual = ucmd.arg(".").run().stdout;
|
||||||
|
let expect = at.root_dir_resolved() + "\n";
|
||||||
|
println!("actual: {:?}", actual);
|
||||||
|
println!("expect: {:?}", expect);
|
||||||
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -12,12 +16,20 @@ fn test_long_redirection_to_current_dir() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
// Create a 256-character path to current directory
|
// Create a 256-character path to current directory
|
||||||
let dir = path_concat!(".", ..128);
|
let dir = path_concat!(".", ..128);
|
||||||
ucmd.arg(dir).run().stdout_is(at.root_dir_resolved() + "\n");
|
let actual = ucmd.arg(dir).run().stdout;
|
||||||
|
let expect = at.root_dir_resolved() + "\n";
|
||||||
|
println!("actual: {:?}", actual);
|
||||||
|
println!("expect: {:?}", expect);
|
||||||
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_long_redirection_to_root() {
|
fn test_long_redirection_to_root() {
|
||||||
// Create a 255-character path to root
|
// Create a 255-character path to root
|
||||||
let dir = path_concat!("..", ..85);
|
let dir = path_concat!("..", ..85);
|
||||||
new_ucmd!().arg(dir).run().stdout_is(get_root_path().to_owned() + "\n");
|
let actual = new_ucmd!().arg(dir).run().stdout;
|
||||||
|
let expect = get_root_path().to_owned() + "\n";
|
||||||
|
println!("actual: {:?}", actual);
|
||||||
|
println!("expect: {:?}", expect);
|
||||||
|
assert_eq!(actual, expect);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue