Skip to content

Commit

Permalink
Auto merge of #56680 - vakaras:issue56280, r=nagisa
Browse files Browse the repository at this point in the history
Use compiletest timestamp to check if the tests should be rerun.

An attempt to fix  #56280 by checking if timestamps of compile test files are older than the timestamp of the stamp file.

?r nagisa
  • Loading branch information
bors committed Dec 22, 2018
2 parents fa922ab + d966e57 commit 9723a49
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ dependencies = [
"serde 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ serde_json = "1.0"
serde_derive = "1.0"
rustfix = "0.4.1"
lazy_static = "1.0"
walkdir = "2"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
25 changes: 15 additions & 10 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern crate serde_derive;
extern crate serde_json;
extern crate test;
extern crate rustfix;
extern crate walkdir;

use common::CompareMode;
use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
Expand All @@ -43,6 +44,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;
use test::ColorConfig;
use util::logv;
use walkdir::WalkDir;

use self::header::{EarlyProps, Ignore};

Expand Down Expand Up @@ -682,6 +684,15 @@ fn stamp(config: &Config, testpaths: &TestPaths, revision: Option<&str>) -> Path
output_base_dir(config, testpaths, revision).join("stamp")
}

/// Return an iterator over timestamps of files in the directory at `path`.
fn collect_timestamps(path: &PathBuf) -> impl Iterator<Item=FileTime> {
WalkDir::new(path)
.into_iter()
.map(|entry| entry.unwrap())
.filter(|entry| entry.metadata().unwrap().is_file())
.map(|entry| mtime(entry.path()))
}

fn up_to_date(
config: &Config,
testpaths: &TestPaths,
Expand Down Expand Up @@ -725,16 +736,7 @@ fn up_to_date(
for pretty_printer_file in &pretty_printer_files {
inputs.push(mtime(&rust_src_dir.join(pretty_printer_file)));
}
let mut entries = config.run_lib_path.read_dir().unwrap().collect::<Vec<_>>();
while let Some(entry) = entries.pop() {
let entry = entry.unwrap();
let path = entry.path();
if entry.metadata().unwrap().is_file() {
inputs.push(mtime(&path));
} else {
entries.extend(path.read_dir().unwrap());
}
}
inputs.extend(collect_timestamps(&config.run_lib_path));
if let Some(ref rustdoc_path) = config.rustdoc_path {
inputs.push(mtime(&rustdoc_path));
inputs.push(mtime(&rust_src_dir.join("src/etc/htmldocck.py")));
Expand All @@ -746,6 +748,9 @@ fn up_to_date(
inputs.push(mtime(path));
}

// Compiletest itself.
inputs.extend(collect_timestamps(&rust_src_dir.join("src/tools/compiletest/")));

inputs.iter().any(|input| *input > stamp)
}

Expand Down

0 comments on commit 9723a49

Please sign in to comment.