diff options
| author | bors <bors@rust-lang.org> | 2021-01-04 09:23:01 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-01-04 09:23:01 +0000 |
| commit | 895191628d6eda2be70f304a69ddb728a912f696 (patch) | |
| tree | f24dcc34a73b4302d048dda8088e734867b978ab | |
| parent | a02806e00d24f0fcb3e1f285ad9c25ed52ed7c8c (diff) | |
| parent | 69090550cb4e46d75506a200b990e9edf2485fd8 (diff) | |
| download | rust-895191628d6eda2be70f304a69ddb728a912f696.tar.gz rust-895191628d6eda2be70f304a69ddb728a912f696.zip | |
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
| -rw-r--r-- | clippy_dev/src/bless.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/clippy_dev/src/bless.rs b/clippy_dev/src/bless.rs index 645098e4cfc..5f66ff4f30e 100644 --- a/clippy_dev/src/bless.rs +++ b/clippy_dev/src/bless.rs @@ -17,26 +17,28 @@ pub static CARGO_TARGET_DIR: SyncLazy<PathBuf> = SyncLazy::new(|| match env::var }); pub fn bless() { - let test_dirs = [ + let test_suite_dirs = [ clippy_project_root().join("tests").join("ui"), clippy_project_root().join("tests").join("ui-toml"), clippy_project_root().join("tests").join("ui-cargo"), ]; - for test_dir in &test_dirs { - WalkDir::new(test_dir) + for test_suite_dir in &test_suite_dirs { + WalkDir::new(test_suite_dir) .into_iter() .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_suite_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, |
