fix: stabilize directory output order

This commit is contained in:
Dandaedre 2026-09-29 16:04:20 +02:00
parent c763b3e664
commit 27b4d70962
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
2 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ impl WalkDocuments {
entries: WalkDir::new(root)
.follow_links(false)
.max_depth(limits.max_walk_depth)
.sort_by_file_name()
.into_iter(),
limits: limits.clone(),
}

View File

@ -224,6 +224,25 @@ fn multiple_files_and_findings_keep_requested_and_span_order() {
);
}
#[test]
fn directory_output_is_sorted_by_path() {
let directory = tempdir().unwrap();
let later = directory.path().join("z-later.txt");
let earlier = directory.path().join("a-earlier.txt");
fs::write(&later, "later").unwrap();
fs::write(&earlier, "earlier").unwrap();
let output = detector()
.args(["--output", "json"])
.arg(directory.path())
.output()
.unwrap();
let records = json_records(&output);
assert_eq!(records[0]["source"], earlier.display().to_string());
assert_eq!(records[1]["source"], later.display().to_string());
}
#[test]
fn missing_path_does_not_hide_a_later_document() {
let directory = tempdir().unwrap();