mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
ls: Fix device display (#2855)
This commit is contained in:
parent
3cc1fb593a
commit
fd5310411e
2 changed files with 160 additions and 23 deletions
|
@ -56,8 +56,70 @@ fn test_ls_ordering() {
|
|||
.stdout_matches(&Regex::new("some-dir1:\\ntotal 0").unwrap());
|
||||
}
|
||||
|
||||
//#[cfg(all(feature = "mknod"))]
|
||||
#[test]
|
||||
fn test_ls_devices() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
at.mkdir("some-dir1");
|
||||
|
||||
// Regex tests correct device ID and correct (no pad) spacing for a single file
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
{
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-al")
|
||||
.arg("/dev/null")
|
||||
.succeeds()
|
||||
.stdout_matches(&Regex::new("[^ ] 3, 2 [^ ]").unwrap());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-al")
|
||||
.arg("/dev/null")
|
||||
.succeeds()
|
||||
.stdout_matches(&Regex::new("[^ ] 1, 3 [^ ]").unwrap());
|
||||
}
|
||||
|
||||
// Regex tests alignment against a file (stdout is a link to a tty)
|
||||
#[cfg(unix)]
|
||||
{
|
||||
let res = scene
|
||||
.ucmd()
|
||||
.arg("-alL")
|
||||
.arg("/dev/null")
|
||||
.arg("/dev/stdout")
|
||||
.succeeds();
|
||||
|
||||
let null_len = String::from_utf8(res.stdout().to_owned())
|
||||
.ok()
|
||||
.unwrap()
|
||||
.lines()
|
||||
.next()
|
||||
.unwrap()
|
||||
.strip_suffix("/dev/null")
|
||||
.unwrap()
|
||||
.len();
|
||||
|
||||
let stdout_len = String::from_utf8(res.stdout().to_owned())
|
||||
.ok()
|
||||
.unwrap()
|
||||
.lines()
|
||||
.nth(1)
|
||||
.unwrap()
|
||||
.strip_suffix("/dev/stdout")
|
||||
.unwrap()
|
||||
.len();
|
||||
|
||||
assert_eq!(stdout_len, null_len);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "chmod"))]
|
||||
#[test]
|
||||
#[cfg(feature = "chmod")]
|
||||
fn test_ls_io_errors() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue