2015-11-16 05:25:01 +00:00
|
|
|
use common::util::*;
|
|
|
|
|
|
|
|
|
|
|
|
static GIBBERISH: &'static str = "supercalifragilisticexpialidocious";
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_canonicalize() {
|
2016-08-23 11:52:43 +00:00
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
2016-08-13 21:59:21 +00:00
|
|
|
ucmd.arg("-f")
|
|
|
|
.arg(".")
|
|
|
|
.run()
|
|
|
|
.stdout_is(at.root_dir_resolved());
|
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!();
|
2016-08-13 21:59:21 +00:00
|
|
|
ucmd.arg("-e")
|
|
|
|
.arg(".")
|
|
|
|
.run()
|
|
|
|
.stdout_is(at.root_dir_resolved());
|
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!();
|
2016-03-29 01:06:31 +00:00
|
|
|
let expected = path_concat!(at.root_dir_resolved(), GIBBERISH);
|
2016-08-13 21:59:21 +00:00
|
|
|
ucmd.arg("-m")
|
|
|
|
.arg(GIBBERISH)
|
|
|
|
.run()
|
|
|
|
.stdout_is(expected);
|
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);
|
2016-08-13 21:59:21 +00:00
|
|
|
ucmd.arg("-n")
|
|
|
|
.arg("-m")
|
|
|
|
.arg(dir)
|
|
|
|
.run()
|
|
|
|
.stdout_is(at.root_dir_resolved());
|
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);
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-08-13 21:59:21 +00:00
|
|
|
.arg("-n")
|
|
|
|
.arg("-m")
|
|
|
|
.arg(dir)
|
|
|
|
.run()
|
|
|
|
.stdout_is(get_root_path());
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|