about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPietro Albini <pietro.albini@ferrous-systems.com>2023-04-14 12:14:19 +0200
committerPietro Albini <pietro.albini@ferrous-systems.com>2023-04-14 12:14:19 +0200
commit0f8a06b6c070b2c79228fcb6cd0dc210fcb7869a (patch)
treed21bca88f3f622abc90a7527585eca11b7331ed8 /src
parent0f364ac3821a58411407f2fd1547ae823f8f0143 (diff)
downloadrust-0f8a06b6c070b2c79228fcb6cd0dc210fcb7869a.tar.gz
rust-0f8a06b6c070b2c79228fcb6cd0dc210fcb7869a.zip
use a shared headers cache
Diffstat (limited to 'src')
-rw-r--r--src/tools/compiletest/src/header.rs16
-rw-r--r--src/tools/compiletest/src/header/tests.rs6
-rw-r--r--src/tools/compiletest/src/main.rs15
3 files changed, 28 insertions, 9 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 91a23776de7..02382f8d4c6 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -11,6 +11,7 @@ use tracing::*;
 use crate::common::{Config, Debugger, FailMode, Mode, PassMode};
 use crate::header::cfg::parse_cfg_name_directive;
 use crate::header::cfg::MatchOutcome;
+use crate::header::needs::CachedNeedsConditions;
 use crate::{extract_cdb_version, extract_gdb_version};
 
 mod cfg;
@@ -18,6 +19,16 @@ mod needs;
 #[cfg(test)]
 mod tests;
 
+pub struct HeadersCache {
+    needs: CachedNeedsConditions,
+}
+
+impl HeadersCache {
+    pub fn load(config: &Config) -> Self {
+        Self { needs: CachedNeedsConditions::load(config) }
+    }
+}
+
 /// Properties which must be known very early, before actually running
 /// the test.
 #[derive(Default)]
@@ -849,6 +860,7 @@ where
 
 pub fn make_test_description<R: Read>(
     config: &Config,
+    cache: &HeadersCache,
     name: test::TestName,
     path: &Path,
     src: R,
@@ -859,8 +871,6 @@ pub fn make_test_description<R: Read>(
     let mut ignore_message = None;
     let mut should_fail = false;
 
-    let needs_cache = needs::CachedNeedsConditions::load(config);
-
     iter_header(path, src, &mut |revision, ln, line_number| {
         if revision.is_some() && revision != cfg {
             return;
@@ -888,7 +898,7 @@ pub fn make_test_description<R: Read>(
 
         decision!(cfg::handle_ignore(config, ln));
         decision!(cfg::handle_only(config, ln));
-        decision!(needs::handle_needs(&needs_cache, config, ln));
+        decision!(needs::handle_needs(&cache.needs, config, ln));
         decision!(ignore_llvm(config, ln));
         decision!(ignore_cdb(config, ln));
         decision!(ignore_gdb(config, ln));
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index 8ee8aa14401..9af7bd5e201 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -2,7 +2,7 @@ use std::io::Read;
 use std::path::Path;
 
 use crate::common::{Config, Debugger};
-use crate::header::{parse_normalization_string, EarlyProps};
+use crate::header::{parse_normalization_string, EarlyProps, HeadersCache};
 
 fn make_test_description<R: Read>(
     config: &Config,
@@ -11,8 +11,10 @@ fn make_test_description<R: Read>(
     src: R,
     cfg: Option<&str>,
 ) -> test::TestDesc {
+    let cache = HeadersCache::load(config);
     let mut poisoned = false;
-    let test = crate::header::make_test_description(config, name, path, src, cfg, &mut poisoned);
+    let test =
+        crate::header::make_test_description(config, &cache, name, path, src, cfg, &mut poisoned);
     if poisoned {
         panic!("poisoned!");
     }
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 5bffd05dbd5..0e49822c1b7 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -25,6 +25,7 @@ use tracing::*;
 use walkdir::WalkDir;
 
 use self::header::{make_test_description, EarlyProps};
+use crate::header::HeadersCache;
 use std::sync::Arc;
 
 #[cfg(test)]
@@ -556,9 +557,11 @@ pub fn make_tests(
         panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
     });
 
+    let cache = HeadersCache::load(&config);
     let mut poisoned = false;
     collect_tests_from_dir(
         config.clone(),
+        &cache,
         &config.src_base,
         &PathBuf::new(),
         &inputs,
@@ -636,6 +639,7 @@ fn modified_tests(config: &Config, dir: &Path) -> Result<Vec<PathBuf>, String> {
 
 fn collect_tests_from_dir(
     config: Arc<Config>,
+    cache: &HeadersCache,
     dir: &Path,
     relative_dir_path: &Path,
     inputs: &Stamp,
@@ -654,7 +658,7 @@ fn collect_tests_from_dir(
             file: dir.to_path_buf(),
             relative_dir: relative_dir_path.parent().unwrap().to_path_buf(),
         };
-        tests.extend(make_test(config, &paths, inputs, poisoned));
+        tests.extend(make_test(config, cache, &paths, inputs, poisoned));
         return Ok(());
     }
 
@@ -680,13 +684,14 @@ fn collect_tests_from_dir(
             let paths =
                 TestPaths { file: file_path, relative_dir: relative_dir_path.to_path_buf() };
 
-            tests.extend(make_test(config.clone(), &paths, inputs, poisoned))
+            tests.extend(make_test(config.clone(), cache, &paths, inputs, poisoned))
         } else if file_path.is_dir() {
             let relative_file_path = relative_dir_path.join(file.file_name());
             if &file_name != "auxiliary" {
                 debug!("found directory: {:?}", file_path.display());
                 collect_tests_from_dir(
                     config.clone(),
+                    cache,
                     &file_path,
                     &relative_file_path,
                     inputs,
@@ -718,6 +723,7 @@ pub fn is_test(file_name: &OsString) -> bool {
 
 fn make_test(
     config: Arc<Config>,
+    cache: &HeadersCache,
     testpaths: &TestPaths,
     inputs: &Stamp,
     poisoned: &mut bool,
@@ -745,8 +751,9 @@ fn make_test(
                 std::fs::File::open(&test_path).expect("open test file to parse ignores");
             let cfg = revision.map(|v| &**v);
             let test_name = crate::make_test_name(&config, testpaths, revision);
-            let mut desc =
-                make_test_description(&config, test_name, &test_path, src_file, cfg, poisoned);
+            let mut desc = make_test_description(
+                &config, cache, test_name, &test_path, src_file, cfg, poisoned,
+            );
             // Ignore tests that already run and are up to date with respect to inputs.
             if !config.force_rerun {
                 desc.ignore |= is_up_to_date(