Skip to content

Commit 6b37932

Browse files
committed
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.
1 parent 0d8a27a commit 6b37932

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

clippy_dev/src/bless.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ pub fn bless() {
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_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)