|
10 | 10 |
|
11 | 11 | //! Tidy check to ensure that there are no stray `.stderr` files in UI test directories.
|
12 | 12 |
|
| 13 | +use std::fs; |
13 | 14 | use std::path::Path;
|
14 | 15 |
|
15 | 16 | pub fn check(path: &Path, bad: &mut bool) {
|
16 |
| - super::walk_many(&[&path.join("test/ui"), &path.join("test/ui-fulldeps")], |
17 |
| - &mut |_| false, |
18 |
| - &mut |file_path| { |
19 |
| - if let Some(ext) = file_path.extension() { |
20 |
| - if ext == "stderr" || ext == "stdout" { |
21 |
| - // Test output filenames have the format: |
22 |
| - // $testname.stderr |
23 |
| - // $testname.$mode.stderr |
24 |
| - // $testname.$revision.stderr |
25 |
| - // $testname.$revision.$mode.stderr |
26 |
| - // |
27 |
| - // For now, just make sure that there is a corresponding |
28 |
| - // $testname.rs file. |
29 |
| - let testname = file_path.file_name().unwrap() |
30 |
| - .to_str().unwrap() |
31 |
| - .splitn(2, '.').next().unwrap(); |
32 |
| - if !file_path.with_file_name(testname) |
33 |
| - .with_extension("rs") |
34 |
| - .exists() { |
35 |
| - println!("Stray file with UI testing output: {:?}", file_path); |
36 |
| - *bad = true; |
| 17 | + super::walk_many( |
| 18 | + &[&path.join("test/ui"), &path.join("test/ui-fulldeps")], |
| 19 | + &mut |_| false, |
| 20 | + &mut |file_path| { |
| 21 | + if let Some(ext) = file_path.extension() { |
| 22 | + if ext == "stderr" || ext == "stdout" { |
| 23 | + // Test output filenames have the format: |
| 24 | + // $testname.stderr |
| 25 | + // $testname.$mode.stderr |
| 26 | + // $testname.$revision.stderr |
| 27 | + // $testname.$revision.$mode.stderr |
| 28 | + // |
| 29 | + // For now, just make sure that there is a corresponding |
| 30 | + // $testname.rs file. |
| 31 | + let testname = file_path |
| 32 | + .file_name() |
| 33 | + .unwrap() |
| 34 | + .to_str() |
| 35 | + .unwrap() |
| 36 | + .splitn(2, '.') |
| 37 | + .next() |
| 38 | + .unwrap(); |
| 39 | + if !file_path |
| 40 | + .with_file_name(testname) |
| 41 | + .with_extension("rs") |
| 42 | + .exists() |
| 43 | + { |
| 44 | + println!("Stray file with UI testing output: {:?}", file_path); |
| 45 | + *bad = true; |
| 46 | + } |
| 47 | + |
| 48 | + if let Ok(metadata) = fs::metadata(file_path) { |
| 49 | + if metadata.len() == 0 { |
| 50 | + println!("Empty file with UI testing output: {:?}", file_path); |
| 51 | + *bad = true; |
| 52 | + } |
| 53 | + } |
37 | 54 | }
|
38 | 55 | }
|
39 |
| - } |
40 |
| - }); |
| 56 | + }, |
| 57 | + ); |
41 | 58 | }
|
0 commit comments