Skip to content

Commit

Permalink
Rename inputs to common_inputs_stamp
Browse files Browse the repository at this point in the history
The new name makes it clearer that this is a timestamp, and is collected from
input files considered common to all tests.
  • Loading branch information
Zalathar committed Oct 18, 2024
1 parent 932e9f0 commit c4c62a5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
struct TestCollectorCx {
config: Arc<Config>,
cache: HeadersCache,
inputs: Stamp,
common_inputs_stamp: Stamp,
modified_tests: Vec<PathBuf>,
}

Expand All @@ -565,13 +565,13 @@ struct TestCollector {
/// because filtering is handled later by libtest.
pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
debug!("making tests from {:?}", config.src_base.display());
let inputs = common_inputs_stamp(&config);
let common_inputs_stamp = common_inputs_stamp(&config);
let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
});
let cache = HeadersCache::load(&config);

let cx = TestCollectorCx { config, cache, inputs, modified_tests };
let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests };
let mut collector =
TestCollector { tests: vec![], found_paths: HashSet::new(), poisoned: false };

Expand All @@ -592,7 +592,13 @@ pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
tests
}

/// Returns a stamp constructed from input files common to all test cases.
/// Returns the most recent last-modified timestamp from among the input files
/// that are considered relevant to all tests (e.g. the compiler, std, and
/// compiletest itself).
///
/// (Some of these inputs aren't actually relevant to _all_ tests, but they are
/// common to some subset of tests, and are hopefully unlikely to be modified
/// while working on other tests.)
fn common_inputs_stamp(config: &Config) -> Stamp {
let rust_src_dir = config.find_rust_src_root().expect("Could not find Rust source root");

Expand Down Expand Up @@ -902,14 +908,14 @@ fn is_up_to_date(

// Check the timestamp of the stamp file against the last modified time
// of all files known to be relevant to the test.
let mut inputs = cx.inputs.clone();
let mut inputs_stamp = cx.common_inputs_stamp.clone();
for path in files_related_to_test(&cx.config, testpaths, props, revision) {
inputs.add_path(&path);
inputs_stamp.add_path(&path);
}

// If no relevant files have been modified since the stamp file was last
// written, the test is up-to-date.
inputs < Stamp::from_path(&stamp_name)
inputs_stamp < Stamp::from_path(&stamp_name)
}

/// The maximum of a set of file-modified timestamps.
Expand Down

0 comments on commit c4c62a5

Please sign in to comment.