mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
tests/ls: add --group-directories-first test
This commit is contained in:
parent
c4606266e4
commit
0b24839a1e
1 changed files with 53 additions and 0 deletions
|
@ -1301,6 +1301,59 @@ fn test_ls_deref() {
|
||||||
assert!(!re.is_match(result.stdout_str().trim()));
|
assert!(!re.is_match(result.stdout_str().trim()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_ls_group_directories_first() {
|
||||||
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
let mut filenames = ["file1", "file2", "anotherFile", "abc", "xxx", "zzz"];
|
||||||
|
for filename in filenames {
|
||||||
|
at.touch(filename);
|
||||||
|
}
|
||||||
|
filenames.sort_unstable();
|
||||||
|
|
||||||
|
let dirnames = ["aaa", "bbb", "ccc", "yyy"];
|
||||||
|
for dirname in dirnames {
|
||||||
|
at.mkdir(dirname);
|
||||||
|
}
|
||||||
|
|
||||||
|
let dots = [".", ".."];
|
||||||
|
|
||||||
|
let result = scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-1a")
|
||||||
|
.arg("--group-directories-first")
|
||||||
|
.run();
|
||||||
|
assert_eq!(
|
||||||
|
result.stdout_str().split('\n').collect::<Vec<_>>(),
|
||||||
|
dots.into_iter()
|
||||||
|
.chain(dirnames.into_iter())
|
||||||
|
.chain(filenames.into_iter())
|
||||||
|
.chain([""].into_iter())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let result = scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-1ar")
|
||||||
|
.arg("--group-directories-first")
|
||||||
|
.run();
|
||||||
|
assert_eq!(
|
||||||
|
result.stdout_str().split('\n').collect::<Vec<_>>(),
|
||||||
|
(dirnames.into_iter().rev())
|
||||||
|
.chain(dots.into_iter().rev())
|
||||||
|
.chain(filenames.into_iter().rev())
|
||||||
|
.chain([""].into_iter())
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let result = scene
|
||||||
|
.ucmd()
|
||||||
|
.arg("-1aU")
|
||||||
|
.arg("--group-directories-first")
|
||||||
|
.run();
|
||||||
|
let result2 = scene.ucmd().arg("-1aU").run();
|
||||||
|
assert_eq!(result.stdout_str(), result2.stdout_str());
|
||||||
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_ls_sort_none() {
|
fn test_ls_sort_none() {
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue