mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Add -e/-m to realpath
This commit is contained in:
parent
68e89c7ea3
commit
625c3f2330
2 changed files with 79 additions and 3 deletions
|
@ -1,5 +1,9 @@
|
|||
use crate::common::util::*;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
static GIBBERISH: &str = "supercalifragilisticexpialidocious";
|
||||
|
||||
#[test]
|
||||
fn test_realpath_current_directory() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -159,3 +163,42 @@ fn test_realpath_loop() {
|
|||
.succeeds()
|
||||
.stdout_only(at.plus_as_string("2\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_default_allows_final_non_existent() {
|
||||
let p = Path::new("").join(GIBBERISH);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let expect = path_concat!(at.root_dir_resolved(), p.to_str().unwrap()) + "\n";
|
||||
ucmd.arg(p.as_os_str()).succeeds().stdout_only(expect);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_default_forbids_non_final_non_existent() {
|
||||
let p = Path::new("").join(GIBBERISH).join(GIBBERISH);
|
||||
new_ucmd!().arg(p.to_str().unwrap()).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_existing() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.arg("-e")
|
||||
.arg(".")
|
||||
.succeeds()
|
||||
.stdout_only(at.plus_as_string(&format!("{}\n", at.root_dir_resolved())));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_existing_error() {
|
||||
new_ucmd!().arg("-e").arg(GIBBERISH).fails();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_realpath_missing() {
|
||||
let p = Path::new("").join(GIBBERISH).join(GIBBERISH);
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let expect = path_concat!(at.root_dir_resolved(), p.to_str().unwrap()) + "\n";
|
||||
ucmd.arg("-m")
|
||||
.arg(p.as_os_str())
|
||||
.succeeds()
|
||||
.stdout_only(expect);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue