Skip to content

Commit 8951916

Browse files
committed
Auto merge of #6525 - phansch:fix-bless-in-subdirs, r=flip1995
Fix blessing of test output in subdirectories The core issue was the usage of `reference_file_path.file_name()`, which provided a non-existent path if the file to be updated was in a subdirectory. Instead we have to provide the whole path after 'tests/ui/' as the 'filename'. This part of the path is called `test_name` in the code now. changelog: none
2 parents a02806e + 6909055 commit 8951916

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

clippy_dev/src/bless.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,28 @@ pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var
1717
});
1818

1919
pub fn bless() {
20-
let test_dirs = [
20+
let test_suite_dirs = [
2121
clippy_project_root().join("tests").join("ui"),
2222
clippy_project_root().join("tests").join("ui-toml"),
2323
clippy_project_root().join("tests").join("ui-cargo"),
2424
];
25-
for test_dir in &test_dirs {
26-
WalkDir::new(test_dir)
25+
for test_suite_dir in &test_suite_dirs {
26+
WalkDir::new(test_suite_dir)
2727
.into_iter()
2828
.filter_map(Result::ok)
2929
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
3030
.for_each(|f| {
31-
update_reference_file(f.path().with_extension("stdout"));
32-
update_reference_file(f.path().with_extension("stderr"));
33-
update_reference_file(f.path().with_extension("fixed"));
31+
let test_name = f.path().strip_prefix(test_suite_dir).unwrap();
32+
33+
update_reference_file(f.path().with_extension("stdout"), test_name.with_extension("stdout"));
34+
update_reference_file(f.path().with_extension("stderr"), test_name.with_extension("stderr"));
35+
update_reference_file(f.path().with_extension("fixed"), test_name.with_extension("fixed"));
3436
});
3537
}
3638
}
3739

38-
fn update_reference_file(reference_file_path: PathBuf) {
39-
let test_output_path = build_dir().join(PathBuf::from(reference_file_path.file_name().unwrap()));
40+
fn update_reference_file(reference_file_path: PathBuf, test_name: PathBuf) {
41+
let test_output_path = build_dir().join(test_name);
4042
let relative_reference_file_path = reference_file_path.strip_prefix(clippy_project_root()).unwrap();
4143

4244
// If compiletest did not write any changes during the test run,

0 commit comments

Comments
 (0)