diff options
| author | Philipp Hansch <dev@phansch.net> | 2020-12-31 12:49:43 +0100 |
|---|---|---|
| committer | Philipp Hansch <dev@phansch.net> | 2020-12-31 12:49:43 +0100 |
| commit | 6b379322686c8b1552b2014ed560822de490cf27 (patch) | |
| tree | fe85c58b083b2939cf56a02e9141adb6085d46e4 | |
| parent | 0d8a27a6f6a1b0cd69f531d34dfbda65bbcf1cfa (diff) | |
| download | rust-6b379322686c8b1552b2014ed560822de490cf27.tar.gz rust-6b379322686c8b1552b2014ed560822de490cf27.zip | |
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.
| -rw-r--r-- | clippy_dev/src/bless.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clippy_dev/src/bless.rs b/clippy_dev/src/bless.rs index 645098e4cfc..48a2458594c 100644 --- a/clippy_dev/src/bless.rs +++ b/clippy_dev/src/bless.rs @@ -28,15 +28,17 @@ pub fn bless() { .filter_map(Result::ok) .filter(|f| f.path().extension() == Some(OsStr::new("rs"))) .for_each(|f| { - update_reference_file(f.path().with_extension("stdout")); - update_reference_file(f.path().with_extension("stderr")); - update_reference_file(f.path().with_extension("fixed")); + let test_name = f.path().strip_prefix(test_dir).unwrap(); + + update_reference_file(f.path().with_extension("stdout"), test_name.with_extension("stdout")); + update_reference_file(f.path().with_extension("stderr"), test_name.with_extension("stderr")); + update_reference_file(f.path().with_extension("fixed"), test_name.with_extension("fixed")); }); } } -fn update_reference_file(reference_file_path: PathBuf) { - let test_output_path = build_dir().join(PathBuf::from(reference_file_path.file_name().unwrap())); +fn update_reference_file(reference_file_path: PathBuf, test_name: PathBuf) { + let test_output_path = build_dir().join(test_name); let relative_reference_file_path = reference_file_path.strip_prefix(clippy_project_root()).unwrap(); // If compiletest did not write any changes during the test run, |
