diff options
| author | kennytm <kennytm@gmail.com> | 2018-05-17 03:07:35 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-05-17 05:18:19 +0800 |
| commit | 63ea42fd3c82c629a0e5a8b981bdaeb30cdc0253 (patch) | |
| tree | 02b249287151f4f5e67c47c1a67bab41c40f3862 /src/tools | |
| parent | 0306630925bf4ab112bf1778bea0b27919b1cc8f (diff) | |
| parent | 6ed200aaeabb7ab2e12c6fd2a52627bd3f457a95 (diff) | |
Rollup merge of #50793 - jrlusby:master, r=petrochenkov
tidy: Add a check for empty UI test files Check for empty `.stderr` and `.stdout` files in UI test directories. Empty files could still pass testing for `compile-pass` tests with no output so they can get into the repo accidentally, but they are not necessary and can be removed. This is very much an in progress pull request. I'm having an issue with rustfmt. It wanted to reformat the entire file for almost every file by default. And when I run tidy it just errors out because it catches the empty files that are already in the repo. My next step is goin got be to remove those empty file and see if running tidy again will actually reformat things outside of the context of `cargo fmt` Fixes https://github.com/rust-lang/rust/issues/50785
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/tidy/src/ui_tests.rs | 63 |
1 files changed, 40 insertions, 23 deletions
diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 351005ff4b8..c1574407807 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -10,32 +10,49 @@ //! Tidy check to ensure that there are no stray `.stderr` files in UI test directories. +use std::fs; use std::path::Path; pub fn check(path: &Path, bad: &mut bool) { - super::walk_many(&[&path.join("test/ui"), &path.join("test/ui-fulldeps")], - &mut |_| false, - &mut |file_path| { - if let Some(ext) = file_path.extension() { - if ext == "stderr" || ext == "stdout" { - // Test output filenames have the format: - // $testname.stderr - // $testname.$mode.stderr - // $testname.$revision.stderr - // $testname.$revision.$mode.stderr - // - // For now, just make sure that there is a corresponding - // $testname.rs file. - let testname = file_path.file_name().unwrap() - .to_str().unwrap() - .splitn(2, '.').next().unwrap(); - if !file_path.with_file_name(testname) - .with_extension("rs") - .exists() { - println!("Stray file with UI testing output: {:?}", file_path); - *bad = true; + super::walk_many( + &[&path.join("test/ui"), &path.join("test/ui-fulldeps")], + &mut |_| false, + &mut |file_path| { + if let Some(ext) = file_path.extension() { + if ext == "stderr" || ext == "stdout" { + // Test output filenames have the format: + // $testname.stderr + // $testname.$mode.stderr + // $testname.$revision.stderr + // $testname.$revision.$mode.stderr + // + // For now, just make sure that there is a corresponding + // $testname.rs file. + let testname = file_path + .file_name() + .unwrap() + .to_str() + .unwrap() + .splitn(2, '.') + .next() + .unwrap(); + if !file_path + .with_file_name(testname) + .with_extension("rs") + .exists() + { + println!("Stray file with UI testing output: {:?}", file_path); + *bad = true; + } + + if let Ok(metadata) = fs::metadata(file_path) { + if metadata.len() == 0 { + println!("Empty file with UI testing output: {:?}", file_path); + *bad = true; + } + } } } - } - }); + }, + ); } |
