]>
Commit | Line | Data |
---|---|---|
0531ce1d XL |
1 | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
11 | //! Tidy check to ensure that there are no stray `.stderr` files in UI test directories. | |
12 | ||
94b46f34 | 13 | use std::fs; |
0531ce1d XL |
14 | use std::path::Path; |
15 | ||
16 | pub fn check(path: &Path, bad: &mut bool) { | |
94b46f34 XL |
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 | } | |
83c7162d | 54 | } |
0531ce1d | 55 | } |
94b46f34 XL |
56 | }, |
57 | ); | |
0531ce1d | 58 | } |