mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #1968 from alstolten/feat2
ls: Implements extension sorting
This commit is contained in:
commit
7dcc8c2960
2 changed files with 81 additions and 2 deletions
|
@ -1696,3 +1696,53 @@ fn test_ls_deref_command_line_dir() {
|
|||
|
||||
assert!(!result.stdout_str().ends_with("sym_dir"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ls_sort_extension() {
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
for filename in &[
|
||||
"file1",
|
||||
"file2",
|
||||
"anotherFile",
|
||||
".hidden",
|
||||
".file.1",
|
||||
".file.2",
|
||||
"file.1",
|
||||
"file.2",
|
||||
"anotherFile.1",
|
||||
"anotherFile.2",
|
||||
"file.ext",
|
||||
"file.debug",
|
||||
"anotherFile.ext",
|
||||
"anotherFile.debug",
|
||||
] {
|
||||
at.touch(filename);
|
||||
}
|
||||
|
||||
let expected = vec![
|
||||
".",
|
||||
"..",
|
||||
".hidden",
|
||||
"anotherFile",
|
||||
"file1",
|
||||
"file2",
|
||||
".file.1",
|
||||
"anotherFile.1",
|
||||
"file.1",
|
||||
".file.2",
|
||||
"anotherFile.2",
|
||||
"file.2",
|
||||
"anotherFile.debug",
|
||||
"file.debug",
|
||||
"anotherFile.ext",
|
||||
"file.ext",
|
||||
"", // because of '\n' at the end of the output
|
||||
];
|
||||
|
||||
let result = scene.ucmd().arg("-1aX").run();
|
||||
assert_eq!(result.stdout_str().split('\n').collect::<Vec<_>>(), expected,);
|
||||
|
||||
let result = scene.ucmd().arg("-1a").arg("--sort=extension").run();
|
||||
assert_eq!(result.stdout_str().split('\n').collect::<Vec<_>>(), expected,);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue