forked from extern/nushell
Fix inconsistency in ls
sort-order (#13875)
Fixes #13267
As we can see from the bisect done in the comments.
Bisected to https://github.com/nushell/nushell/pull/12625 /
460a1c8f87
We can see that this update brought the use of `read_dir` and for it, it
is mentioned in the [rust
docs](https://doc.rust-lang.org/std/fs/fn.read_dir.html#platform-specific-behavior)
that it does **not** provide any specific order of files.
As was the advice there, I went and applied a manual `sort` to the
entries and tested it manually on my local machine.
If required I could probably try and add tests for the order
consistency, would need some time to find my way around them, so I'm
sending the PR first.
This commit is contained in:
@ -833,3 +833,27 @@ fn list_symlink_with_full_path() {
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn consistent_list_order() {
|
||||
Playground::setup("ls_test_order", |dirs, sandbox| {
|
||||
sandbox.with_files(&[
|
||||
EmptyFile("los.txt"),
|
||||
EmptyFile("tres.txt"),
|
||||
EmptyFile("amigos.txt"),
|
||||
EmptyFile("arepas.clu"),
|
||||
]);
|
||||
|
||||
let no_arg = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
"ls"
|
||||
));
|
||||
|
||||
let with_arg = nu!(
|
||||
cwd: dirs.test(), pipeline(
|
||||
"ls ."
|
||||
));
|
||||
|
||||
assert_eq!(no_arg.out, with_arg.out);
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user