提交 5c10185a 编写于 作者: J Jane Lusby

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.
上级 0e325d01
......@@ -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;
}
}
}
}
}
});
},
);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册