2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
2021-05-29 12:32:35 +00:00
|
|
|
static GIBBERISH: &str = "supercalifragilisticexpialidocious";
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_canonicalize() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
2021-04-17 23:28:06 +00:00
|
|
|
let actual = ucmd.arg("-f").arg(".").run().stdout_move_str();
|
2020-01-02 04:39:32 +00:00
|
|
|
let expect = at.root_dir_resolved() + "\n";
|
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
assert_eq!(actual, expect);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_canonicalize_existing() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
2021-04-17 23:28:06 +00:00
|
|
|
let actual = ucmd.arg("-e").arg(".").run().stdout_move_str();
|
2020-01-02 04:39:32 +00:00
|
|
|
let expect = at.root_dir_resolved() + "\n";
|
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
assert_eq!(actual, expect);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_canonicalize_missing() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
2021-04-17 23:28:06 +00:00
|
|
|
let actual = ucmd.arg("-m").arg(GIBBERISH).run().stdout_move_str();
|
2020-01-02 04:39:32 +00:00
|
|
|
let expect = path_concat!(at.root_dir_resolved(), GIBBERISH) + "\n";
|
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
assert_eq!(actual, expect);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_long_redirection_to_current_dir() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
2015-11-16 05:25:01 +00:00
|
|
|
// Create a 256-character path to current directory
|
2016-03-29 01:06:31 +00:00
|
|
|
let dir = path_concat!(".", ..128);
|
2021-04-17 23:28:06 +00:00
|
|
|
let actual = ucmd.arg("-n").arg("-m").arg(dir).run().stdout_move_str();
|
2020-01-02 04:39:32 +00:00
|
|
|
let expect = at.root_dir_resolved();
|
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
assert_eq!(actual, expect);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_long_redirection_to_root() {
|
|
|
|
// Create a 255-character path to root
|
2016-03-29 01:06:31 +00:00
|
|
|
let dir = path_concat!("..", ..85);
|
2021-04-17 23:28:06 +00:00
|
|
|
let actual = new_ucmd!()
|
|
|
|
.arg("-n")
|
|
|
|
.arg("-m")
|
|
|
|
.arg(dir)
|
|
|
|
.run()
|
|
|
|
.stdout_move_str();
|
2020-01-02 04:39:32 +00:00
|
|
|
let expect = get_root_path();
|
|
|
|
println!("actual: {:?}", actual);
|
|
|
|
println!("expect: {:?}", expect);
|
|
|
|
assert_eq!(actual, expect);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|