Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: rename test modules to avoid case-insensitive path collisions
Cloning the repo on case-insensitive filesystems (e.g. Windows, macOS)
produces git warnings because the following directories collide:

  tests/{source,target}/reorder_modules/ABCD vs abcd
  tests/{source,target}/reorder_modules/ZYXW vs zyxw
  tests/{source,target}/reorder_modules_2027/ABCD vs abcd
  tests/{source,target}/reorder_modules_2027/ZYXW vs zyxw

These were added in 2d049af (#6368) to test
case-sensitive module sorting across style editions. The collision on
case-insensitive filesystems was not considered.

Rename the lowercase variants (abcd -> abcde, zyxw -> zyxwv) to
eliminate collisions while preserving the test intent.

Also add a unit test (no_case_insensitive_path_collisions) to prevent
future collisions, as suggested by @ytmimi.
  • Loading branch information
cataggar committed Mar 31, 2026
commit db0ddd910d06546eb419ab5970406b60cc316eba
52 changes: 52 additions & 0 deletions src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,58 @@ fn verify_config_test_names() {
}
}

// Collects all file and directory paths under `root` (relative to `root`).
fn collect_paths(root: &Path) -> Vec<PathBuf> {
let mut paths = Vec::new();
let mut stack = vec![root.to_path_buf()];
while let Some(dir) = stack.pop() {
for entry in fs::read_dir(&dir).expect(&format!("couldn't read {}", dir.display())) {
let entry = entry.expect("couldn't get DirEntry");
let path = entry.path();
paths.push(path.strip_prefix(root).unwrap().to_path_buf());
if path.is_dir() {
stack.push(path);
}
}
}
paths
}

#[test]
fn no_case_insensitive_path_collisions() {
// Ensure no two paths in test directories differ only by case,
// which causes warnings when cloning on case-insensitive filesystems
// (e.g. Windows, macOS).
let test_dirs = [Path::new("tests/source"), Path::new("tests/target")];
let mut collisions = Vec::new();

for root in &test_dirs {
let mut seen: HashMap<String, PathBuf> = HashMap::new();
for path in collect_paths(root) {
let key = path.to_string_lossy().to_lowercase();
if let Some(existing) = seen.get(&key) {
if *existing != path {
collisions.push(format!(
"{}/{} collides with {}/{}",
root.display(),
existing.display(),
root.display(),
path.display(),
));
}
} else {
seen.insert(key, path);
}
}
}

assert!(
collisions.is_empty(),
"Case-insensitive path collisions found (these cause warnings on Windows/macOS):\n {}",
collisions.join("\n ")
);
}

// This writes to the terminal using the same approach (via `term::stdout` or
// `println!`) that is used by `rustfmt::rustfmt_diff::print_diff`. Writing
// using only one or the other will cause the output order to differ when
Expand Down
4 changes: 2 additions & 2 deletions tests/source/reorder_modules/disabled_style_edition_2024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
4 changes: 2 additions & 2 deletions tests/source/reorder_modules/enabled_style_edition_2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
4 changes: 2 additions & 2 deletions tests/source/reorder_modules/enabled_style_edition_2024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
Empty file.
1 change: 1 addition & 0 deletions tests/target/reorder_modules/abcde/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions tests/target/reorder_modules/disabled_style_edition_2024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
4 changes: 2 additions & 2 deletions tests/target/reorder_modules/enabled_style_edition_2015.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod Z_YXW;
mod _ZYXW;
mod _abcd;
mod a1;
mod abcd;
mod abcde;
mod u128;
mod u16;
mod u256;
Expand Down Expand Up @@ -44,4 +44,4 @@ mod x86_128;
mod x86_32;
mod x86_64;
mod x87;
mod zyxw;
mod zyxwv;
4 changes: 2 additions & 2 deletions tests/target/reorder_modules/enabled_style_edition_2024.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod Z_YXW;
mod _ZYXW;
mod _abcd;
mod a1;
mod abcd;
mod abcde;
mod u128;
mod u16;
mod u256;
Expand Down Expand Up @@ -44,4 +44,4 @@ mod x86_128;
mod x86_32;
mod x86_64;
mod x87;
mod zyxw;
mod zyxwv;
1 change: 1 addition & 0 deletions tests/target/reorder_modules/zyxwv/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file.
1 change: 1 addition & 0 deletions tests/target/reorder_modules_2027/abcde/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod x86;
mod v0s;
mod v001;
mod x87;
mod zyxw;
mod zyxwv;
mod A2;
mod ZYXW;
mod w5s009t;
Expand Down Expand Up @@ -36,7 +36,7 @@ mod _abcd;
mod ABCD;
mod Z_YXW;
mod u64;
mod abcd;
mod abcde;
mod ZYXW_;
mod u16;
mod uz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod ZY_XW;
mod ZYXW;
mod ZYXW_;
mod a1;
mod abcd;
mod abcde;
mod u_zzz;
mod u8;
mod u16;
Expand Down Expand Up @@ -44,4 +44,4 @@ mod x86_32;
mod x86_64;
mod x86_128;
mod x87;
mod zyxw;
mod zyxwv;
Empty file.
1 change: 1 addition & 0 deletions tests/target/reorder_modules_2027/zyxwv/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading