Skip to content

Commit 41c562d

Browse files
committed
Improve variable naming
1 parent 4bd9ed9 commit 41c562d

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

clippy_dev/src/bless.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! `bless` updates the 'expected output' files in the repo with changed output files
1+
//! `bless` updates the reference files in the repo with changed output files
22
//! from the last test run.
33
44
use std::env;
@@ -28,35 +28,35 @@ pub fn bless() {
2828
.filter_map(Result::ok)
2929
.filter(|f| f.path().extension() == Some(OsStr::new("rs")))
3030
.for_each(|f| {
31-
update_test_file(f.path().with_extension("stdout"));
32-
update_test_file(f.path().with_extension("stderr"));
33-
update_test_file(f.path().with_extension("fixed"));
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"));
3434
});
3535
}
3636
}
3737

38-
fn update_test_file(test_file_path: PathBuf) {
39-
let build_output_path = build_dir().join(PathBuf::from(test_file_path.file_name().unwrap()));
40-
let relative_test_file_path = test_file_path.strip_prefix(clippy_project_root()).unwrap();
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+
let relative_reference_file_path = reference_file_path.strip_prefix(clippy_project_root()).unwrap();
4141

4242
// If compiletest did not write any changes during the test run,
4343
// we don't have to update anything
44-
if !build_output_path.exists() {
44+
if !test_output_path.exists() {
4545
return;
4646
}
4747

48-
let build_output = fs::read(&build_output_path).expect("Unable to read build output file");
49-
let test_file = fs::read(&test_file_path).expect("Unable to read test file");
48+
let test_output_file = fs::read(&test_output_path).expect("Unable to read test output file");
49+
let reference_file = fs::read(&reference_file_path).expect("Unable to read reference file");
5050

51-
if build_output != test_file {
52-
// If a test run caused an output file to change, update the test file
53-
println!("updating {}", &relative_test_file_path.display());
54-
fs::copy(build_output_path, &test_file_path).expect("Could not update test file");
51+
if test_output_file != reference_file {
52+
// If a test run caused an output file to change, update the reference file
53+
println!("updating {}", &relative_reference_file_path.display());
54+
fs::copy(test_output_path, &reference_file_path).expect("Could not update reference file");
5555

56-
if test_file.is_empty() {
57-
// If we copied over an empty output file, we remove it
58-
println!("removing {}", &relative_test_file_path.display());
59-
fs::remove_file(test_file_path).expect("Could not remove test file");
56+
if reference_file.is_empty() {
57+
// If we copied over an empty output file, we remove the now empty reference file
58+
println!("removing {}", &relative_reference_file_path.display());
59+
fs::remove_file(reference_file_path).expect("Could not remove reference file");
6060
}
6161
}
6262
}

0 commit comments

Comments
 (0)