about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2021-06-13 22:06:11 +0300
committerSimonas Kazlauskas <git@kazlauskas.me>2021-06-24 23:13:08 +0300
commitcfcb2b664d6f1419a6219f88b060dee420736407 (patch)
treea5388c98051df9a0a1bd384e11d8b08b53601445 /src/tools/compiletest
parent493fe8008b33c576240bfa6979760e0e5482d5af (diff)
compiletest: ignore tests on a per-revision basis
Otherwise something that ought to seemingly work like `//[x86]
needs-llvm-components: x86` or `//[nll_beyond]should-fail` do not get
evaluated properly.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/header.rs462
-rw-r--r--src/tools/compiletest/src/header/tests.rs113
-rw-r--r--src/tools/compiletest/src/main.rs64
3 files changed, 296 insertions, 343 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 26c1710be74..764f2055277 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -27,8 +27,6 @@ enum ParsedNameDirective {
 /// the test.
 #[derive(Default)]
 pub struct EarlyProps {
-    pub ignore: bool,
-    pub should_fail: bool,
     pub aux: Vec<String>,
     pub aux_crate: Vec<(String, String)>,
     pub revisions: Vec<String>,
@@ -36,251 +34,22 @@ pub struct EarlyProps {
 
 impl EarlyProps {
     pub fn from_file(config: &Config, testfile: &Path) -> Self {
-        let file = File::open(testfile).unwrap();
+        let file = File::open(testfile).expect("open test file to parse earlyprops");
         Self::from_reader(config, testfile, file)
     }
 
     pub fn from_reader<R: Read>(config: &Config, testfile: &Path, rdr: R) -> Self {
         let mut props = EarlyProps::default();
-        let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
-        let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some();
-        let has_asm_support = util::has_asm_support(&config.target);
-        let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target);
-        let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target);
-        let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target);
-        let has_tsan = util::TSAN_SUPPORTED_TARGETS.contains(&&*config.target);
-        let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
-        // for `-Z gcc-ld=lld`
-        let has_rust_lld = config
-            .compile_lib_path
-            .join("rustlib")
-            .join(&config.target)
-            .join("bin")
-            .join("gcc-ld")
-            .join(if config.host.contains("windows") { "ld.exe" } else { "ld" })
-            .exists();
-
-        iter_header(testfile, None, rdr, &mut |ln| {
-            // we should check if any only-<platform> exists and if it exists
-            // and does not matches the current platform, skip the test
-            if !props.ignore {
-                props.ignore = match config.parse_cfg_name_directive(ln, "ignore") {
-                    ParsedNameDirective::Match => true,
-                    ParsedNameDirective::NoMatch => props.ignore,
-                };
-
-                if config.has_cfg_prefix(ln, "only") {
-                    props.ignore = match config.parse_cfg_name_directive(ln, "only") {
-                        ParsedNameDirective::Match => props.ignore,
-                        ParsedNameDirective::NoMatch => true,
-                    };
-                }
-
-                if ignore_llvm(config, ln) {
-                    props.ignore = true;
-                }
-
-                if config.run_clang_based_tests_with.is_none()
-                    && config.parse_needs_matching_clang(ln)
-                {
-                    props.ignore = true;
-                }
-
-                if !has_asm_support && config.parse_name_directive(ln, "needs-asm-support") {
-                    props.ignore = true;
-                }
-
-                if !rustc_has_profiler_support && config.parse_needs_profiler_support(ln) {
-                    props.ignore = true;
-                }
-
-                if !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled") {
-                    props.ignore = true;
-                }
-
-                if !rustc_has_sanitizer_support
-                    && config.parse_name_directive(ln, "needs-sanitizer-support")
-                {
-                    props.ignore = true;
-                }
-
-                if !has_asan && config.parse_name_directive(ln, "needs-sanitizer-address") {
-                    props.ignore = true;
-                }
-
-                if !has_lsan && config.parse_name_directive(ln, "needs-sanitizer-leak") {
-                    props.ignore = true;
-                }
-
-                if !has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory") {
-                    props.ignore = true;
-                }
-
-                if !has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread") {
-                    props.ignore = true;
-                }
-
-                if !has_hwasan && config.parse_name_directive(ln, "needs-sanitizer-hwaddress") {
-                    props.ignore = true;
-                }
-
-                if config.target_panic == PanicStrategy::Abort
-                    && config.parse_name_directive(ln, "needs-unwind")
-                {
-                    props.ignore = true;
-                }
-
-                if config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln) {
-                    props.ignore = true;
-                }
-
-                if config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln) {
-                    props.ignore = true;
-                }
-
-                if config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln) {
-                    props.ignore = true;
-                }
-
-                if config.debugger == Some(Debugger::Lldb) && ignore_lldb(config, ln) {
-                    props.ignore = true;
-                }
-
-                if !has_rust_lld && config.parse_name_directive(ln, "needs-rust-lld") {
-                    props.ignore = true;
-                }
-            }
-
+        iter_header(testfile, rdr, &mut |_, ln| {
             if let Some(s) = config.parse_aux_build(ln) {
                 props.aux.push(s);
             }
-
             if let Some(ac) = config.parse_aux_crate(ln) {
                 props.aux_crate.push(ac);
             }
-
             config.parse_and_update_revisions(ln, &mut props.revisions);
-
-            props.should_fail = props.should_fail || config.parse_name_directive(ln, "should-fail");
         });
-
         return props;
-
-        fn ignore_cdb(config: &Config, line: &str) -> bool {
-            if let Some(actual_version) = config.cdb_version {
-                if let Some(min_version) = line.strip_prefix("min-cdb-version:").map(str::trim) {
-                    let min_version = extract_cdb_version(min_version).unwrap_or_else(|| {
-                        panic!("couldn't parse version range: {:?}", min_version);
-                    });
-
-                    // Ignore if actual version is smaller than the minimum
-                    // required version
-                    return actual_version < min_version;
-                }
-            }
-            false
-        }
-
-        fn ignore_gdb(config: &Config, line: &str) -> bool {
-            if let Some(actual_version) = config.gdb_version {
-                if let Some(rest) = line.strip_prefix("min-gdb-version:").map(str::trim) {
-                    let (start_ver, end_ver) = extract_version_range(rest, extract_gdb_version)
-                        .unwrap_or_else(|| {
-                            panic!("couldn't parse version range: {:?}", rest);
-                        });
-
-                    if start_ver != end_ver {
-                        panic!("Expected single GDB version")
-                    }
-                    // Ignore if actual version is smaller than the minimum
-                    // required version
-                    return actual_version < start_ver;
-                } else if let Some(rest) = line.strip_prefix("ignore-gdb-version:").map(str::trim) {
-                    let (min_version, max_version) =
-                        extract_version_range(rest, extract_gdb_version).unwrap_or_else(|| {
-                            panic!("couldn't parse version range: {:?}", rest);
-                        });
-
-                    if max_version < min_version {
-                        panic!("Malformed GDB version range: max < min")
-                    }
-
-                    return actual_version >= min_version && actual_version <= max_version;
-                }
-            }
-            false
-        }
-
-        fn ignore_lldb(config: &Config, line: &str) -> bool {
-            if let Some(actual_version) = config.lldb_version {
-                if let Some(min_version) = line.strip_prefix("min-lldb-version:").map(str::trim) {
-                    let min_version = min_version.parse().unwrap_or_else(|e| {
-                        panic!(
-                            "Unexpected format of LLDB version string: {}\n{:?}",
-                            min_version, e
-                        );
-                    });
-                    // Ignore if actual version is smaller the minimum required
-                    // version
-                    actual_version < min_version
-                } else {
-                    line.starts_with("rust-lldb") && !config.lldb_native_rust
-                }
-            } else {
-                false
-            }
-        }
-
-        fn ignore_llvm(config: &Config, line: &str) -> bool {
-            if config.system_llvm && line.starts_with("no-system-llvm") {
-                return true;
-            }
-            if let Some(needed_components) =
-                config.parse_name_value_directive(line, "needs-llvm-components")
-            {
-                let components: HashSet<_> = config.llvm_components.split_whitespace().collect();
-                if let Some(missing_component) = needed_components
-                    .split_whitespace()
-                    .find(|needed_component| !components.contains(needed_component))
-                {
-                    if env::var_os("COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS").is_some() {
-                        panic!("missing LLVM component: {}", missing_component);
-                    }
-                    return true;
-                }
-            }
-            if let Some(actual_version) = config.llvm_version {
-                if let Some(rest) = line.strip_prefix("min-llvm-version:").map(str::trim) {
-                    let min_version = extract_llvm_version(rest).unwrap();
-                    // Ignore if actual version is smaller the minimum required
-                    // version
-                    actual_version < min_version
-                } else if let Some(rest) =
-                    line.strip_prefix("min-system-llvm-version:").map(str::trim)
-                {
-                    let min_version = extract_llvm_version(rest).unwrap();
-                    // Ignore if using system LLVM and actual version
-                    // is smaller the minimum required version
-                    config.system_llvm && actual_version < min_version
-                } else if let Some(rest) = line.strip_prefix("ignore-llvm-version:").map(str::trim)
-                {
-                    // Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
-                    let (v_min, v_max) = extract_version_range(rest, extract_llvm_version)
-                        .unwrap_or_else(|| {
-                            panic!("couldn't parse version range: {:?}", rest);
-                        });
-                    if v_max < v_min {
-                        panic!("Malformed LLVM version range: max < min")
-                    }
-                    // Ignore if version lies inside of range.
-                    actual_version >= v_min && actual_version <= v_max
-                } else {
-                    false
-                }
-            } else {
-                false
-            }
-        }
     }
 }
 
@@ -440,7 +209,11 @@ impl TestProps {
         if !testfile.is_dir() {
             let file = File::open(testfile).unwrap();
 
-            iter_header(testfile, cfg, file, &mut |ln| {
+            iter_header(testfile, file, &mut |revision, ln| {
+                if revision.is_some() && revision != cfg {
+                    return;
+                }
+
                 if let Some(ep) = config.parse_error_pattern(ln) {
                     self.error_patterns.push(ep);
                 }
@@ -672,12 +445,12 @@ impl TestProps {
     }
 }
 
-fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn FnMut(&str)) {
+fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str>, &str)) {
     if testfile.is_dir() {
         return;
     }
 
-    let comment = if testfile.to_string_lossy().ends_with(".rs") { "//" } else { "#" };
+    let comment = if testfile.extension().map(|e| e == "rs") == Some(true) { "//" } else { "#" };
 
     let mut rdr = BufReader::new(rdr);
     let mut ln = String::new();
@@ -699,18 +472,12 @@ fn iter_header<R: Read>(testfile: &Path, cfg: Option<&str>, rdr: R, it: &mut dyn
             if let Some(close_brace) = ln.find(']') {
                 let open_brace = ln.find('[').unwrap();
                 let lncfg = &ln[open_brace + 1..close_brace];
-                let matches = match cfg {
-                    Some(s) => s == &lncfg[..],
-                    None => false,
-                };
-                if matches {
-                    it(ln[(close_brace + 1)..].trim_start());
-                }
+                it(Some(lncfg), ln[(close_brace + 1)..].trim_start());
             } else {
                 panic!("malformed condition directive: expected `{}[foo]`, found `{}`", comment, ln)
             }
         } else if ln.starts_with(comment) {
-            it(ln[comment.len()..].trim_start());
+            it(None, ln[comment.len()..].trim_start());
         }
     }
 }
@@ -1026,11 +793,12 @@ pub fn extract_llvm_version(version: &str) -> Option<u32> {
     Some(version)
 }
 
-// Takes a directive of the form "<version1> [- <version2>]",
-// returns the numeric representation of <version1> and <version2> as
-// tuple: (<version1> as u32, <version2> as u32)
-// If the <version2> part is omitted, the second component of the tuple
-// is the same as <version1>.
+/// Takes a directive of the form "<version1> [- <version2>]",
+/// returns the numeric representation of <version1> and <version2> as
+/// tuple: (<version1> as u32, <version2> as u32)
+///
+/// If the <version2> part is omitted, the second component of the tuple
+/// is the same as <version1>.
 fn extract_version_range<F>(line: &str, parse: F) -> Option<(u32, u32)>
 where
     F: Fn(&str) -> Option<u32>,
@@ -1056,3 +824,199 @@ where
 
     Some((min, max))
 }
+
+pub fn make_test_description<R: Read>(
+    config: &Config,
+    name: test::TestName,
+    path: &Path,
+    src: R,
+    cfg: Option<&str>,
+) -> test::TestDesc {
+    let mut ignore = false;
+    let mut should_fail = false;
+
+    let rustc_has_profiler_support = env::var_os("RUSTC_PROFILER_SUPPORT").is_some();
+    let rustc_has_sanitizer_support = env::var_os("RUSTC_SANITIZER_SUPPORT").is_some();
+    let has_asm_support = util::has_asm_support(&config.target);
+    let has_asan = util::ASAN_SUPPORTED_TARGETS.contains(&&*config.target);
+    let has_lsan = util::LSAN_SUPPORTED_TARGETS.contains(&&*config.target);
+    let has_msan = util::MSAN_SUPPORTED_TARGETS.contains(&&*config.target);
+    let has_tsan = util::TSAN_SUPPORTED_TARGETS.contains(&&*config.target);
+    let has_hwasan = util::HWASAN_SUPPORTED_TARGETS.contains(&&*config.target);
+    // for `-Z gcc-ld=lld`
+    let has_rust_lld = config
+        .compile_lib_path
+        .join("rustlib")
+        .join(&config.target)
+        .join("bin")
+        .join("gcc-ld")
+        .join(if config.host.contains("windows") { "ld.exe" } else { "ld" })
+        .exists();
+    iter_header(path, src, &mut |revision, ln| {
+        if revision.is_some() && revision != cfg {
+            return;
+        }
+        ignore = match config.parse_cfg_name_directive(ln, "ignore") {
+            ParsedNameDirective::Match => true,
+            ParsedNameDirective::NoMatch => ignore,
+        };
+        if config.has_cfg_prefix(ln, "only") {
+            ignore = match config.parse_cfg_name_directive(ln, "only") {
+                ParsedNameDirective::Match => ignore,
+                ParsedNameDirective::NoMatch => true,
+            };
+        }
+        ignore |= ignore_llvm(config, ln);
+        ignore |=
+            config.run_clang_based_tests_with.is_none() && config.parse_needs_matching_clang(ln);
+        ignore |= !has_asm_support && config.parse_name_directive(ln, "needs-asm-support");
+        ignore |= !rustc_has_profiler_support && config.parse_needs_profiler_support(ln);
+        ignore |= !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled");
+        ignore |= !rustc_has_sanitizer_support
+            && config.parse_name_directive(ln, "needs-sanitizer-support");
+        ignore |= !has_asan && config.parse_name_directive(ln, "needs-sanitizer-address");
+        ignore |= !has_lsan && config.parse_name_directive(ln, "needs-sanitizer-leak");
+        ignore |= !has_msan && config.parse_name_directive(ln, "needs-sanitizer-memory");
+        ignore |= !has_tsan && config.parse_name_directive(ln, "needs-sanitizer-thread");
+        ignore |= !has_hwasan && config.parse_name_directive(ln, "needs-sanitizer-hwaddress");
+        ignore |= config.target_panic == PanicStrategy::Abort
+            && config.parse_name_directive(ln, "needs-unwind");
+        ignore |= config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln);
+        ignore |= config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln);
+        ignore |= config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln);
+        ignore |= config.debugger == Some(Debugger::Lldb) && ignore_lldb(config, ln);
+        ignore |= !has_rust_lld && config.parse_name_directive(ln, "needs-rust-lld");
+        should_fail |= config.parse_name_directive(ln, "should-fail");
+    });
+
+    // The `should-fail` annotation doesn't apply to pretty tests,
+    // since we run the pretty printer across all tests by default.
+    // If desired, we could add a `should-fail-pretty` annotation.
+    let should_panic = match config.mode {
+        crate::common::Pretty => test::ShouldPanic::No,
+        _ if should_fail => test::ShouldPanic::Yes,
+        _ => test::ShouldPanic::No,
+    };
+
+    test::TestDesc {
+        name,
+        ignore,
+        should_panic,
+        allow_fail: false,
+        #[cfg(not(bootstrap))]
+        compile_fail: false,
+        #[cfg(not(bootstrap))]
+        no_run: false,
+        test_type: test::TestType::Unknown,
+    }
+}
+
+fn ignore_cdb(config: &Config, line: &str) -> bool {
+    if let Some(actual_version) = config.cdb_version {
+        if let Some(min_version) = line.strip_prefix("min-cdb-version:").map(str::trim) {
+            let min_version = extract_cdb_version(min_version).unwrap_or_else(|| {
+                panic!("couldn't parse version range: {:?}", min_version);
+            });
+
+            // Ignore if actual version is smaller than the minimum
+            // required version
+            return actual_version < min_version;
+        }
+    }
+    false
+}
+
+fn ignore_gdb(config: &Config, line: &str) -> bool {
+    if let Some(actual_version) = config.gdb_version {
+        if let Some(rest) = line.strip_prefix("min-gdb-version:").map(str::trim) {
+            let (start_ver, end_ver) = extract_version_range(rest, extract_gdb_version)
+                .unwrap_or_else(|| {
+                    panic!("couldn't parse version range: {:?}", rest);
+                });
+
+            if start_ver != end_ver {
+                panic!("Expected single GDB version")
+            }
+            // Ignore if actual version is smaller than the minimum
+            // required version
+            return actual_version < start_ver;
+        } else if let Some(rest) = line.strip_prefix("ignore-gdb-version:").map(str::trim) {
+            let (min_version, max_version) = extract_version_range(rest, extract_gdb_version)
+                .unwrap_or_else(|| {
+                    panic!("couldn't parse version range: {:?}", rest);
+                });
+
+            if max_version < min_version {
+                panic!("Malformed GDB version range: max < min")
+            }
+
+            return actual_version >= min_version && actual_version <= max_version;
+        }
+    }
+    false
+}
+
+fn ignore_lldb(config: &Config, line: &str) -> bool {
+    if let Some(actual_version) = config.lldb_version {
+        if let Some(min_version) = line.strip_prefix("min-lldb-version:").map(str::trim) {
+            let min_version = min_version.parse().unwrap_or_else(|e| {
+                panic!("Unexpected format of LLDB version string: {}\n{:?}", min_version, e);
+            });
+            // Ignore if actual version is smaller the minimum required
+            // version
+            actual_version < min_version
+        } else {
+            line.starts_with("rust-lldb") && !config.lldb_native_rust
+        }
+    } else {
+        false
+    }
+}
+
+fn ignore_llvm(config: &Config, line: &str) -> bool {
+    if config.system_llvm && line.starts_with("no-system-llvm") {
+        return true;
+    }
+    if let Some(needed_components) =
+        config.parse_name_value_directive(line, "needs-llvm-components")
+    {
+        let components: HashSet<_> = config.llvm_components.split_whitespace().collect();
+        if let Some(missing_component) = needed_components
+            .split_whitespace()
+            .find(|needed_component| !components.contains(needed_component))
+        {
+            if env::var_os("COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS").is_some() {
+                panic!("missing LLVM component: {}", missing_component);
+            }
+            return true;
+        }
+    }
+    if let Some(actual_version) = config.llvm_version {
+        if let Some(rest) = line.strip_prefix("min-llvm-version:").map(str::trim) {
+            let min_version = extract_llvm_version(rest).unwrap();
+            // Ignore if actual version is smaller the minimum required
+            // version
+            actual_version < min_version
+        } else if let Some(rest) = line.strip_prefix("min-system-llvm-version:").map(str::trim) {
+            let min_version = extract_llvm_version(rest).unwrap();
+            // Ignore if using system LLVM and actual version
+            // is smaller the minimum required version
+            config.system_llvm && actual_version < min_version
+        } else if let Some(rest) = line.strip_prefix("ignore-llvm-version:").map(str::trim) {
+            // Syntax is: "ignore-llvm-version: <version1> [- <version2>]"
+            let (v_min, v_max) =
+                extract_version_range(rest, extract_llvm_version).unwrap_or_else(|| {
+                    panic!("couldn't parse version range: {:?}", rest);
+                });
+            if v_max < v_min {
+                panic!("Malformed LLVM version range: max < min")
+            }
+            // Ignore if version lies inside of range.
+            actual_version >= v_min && actual_version <= v_max
+        } else {
+            false
+        }
+    } else {
+        false
+    }
+}
diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs
index 2c607b6a50e..2485dbadab5 100644
--- a/src/tools/compiletest/src/header/tests.rs
+++ b/src/tools/compiletest/src/header/tests.rs
@@ -1,7 +1,7 @@
 use std::path::Path;
 
 use crate::common::{Config, Debugger};
-use crate::header::{parse_normalization_string, EarlyProps};
+use crate::header::{make_test_description, parse_normalization_string, EarlyProps};
 
 #[test]
 fn test_parse_normalization_string() {
@@ -66,6 +66,13 @@ fn parse_rs(config: &Config, contents: &str) -> EarlyProps {
     EarlyProps::from_reader(config, Path::new("a.rs"), bytes)
 }
 
+fn check_ignore(config: &Config, contents: &str) -> bool {
+    let tn = test::DynTestName(String::new());
+    let p = Path::new("a.rs");
+    let d = make_test_description(&config, tn, p, std::io::Cursor::new(contents), None);
+    d.ignore
+}
+
 fn parse_makefile(config: &Config, contents: &str) -> EarlyProps {
     let bytes = contents.as_bytes();
     EarlyProps::from_reader(config, Path::new("Makefile"), bytes)
@@ -74,9 +81,13 @@ fn parse_makefile(config: &Config, contents: &str) -> EarlyProps {
 #[test]
 fn should_fail() {
     let config = config();
+    let tn = test::DynTestName(String::new());
+    let p = Path::new("a.rs");
 
-    assert!(!parse_rs(&config, "").should_fail);
-    assert!(parse_rs(&config, "// should-fail").should_fail);
+    let d = make_test_description(&config, tn.clone(), p, std::io::Cursor::new(""), None);
+    assert_eq!(d.should_panic, test::ShouldPanic::No);
+    let d = make_test_description(&config, tn, p, std::io::Cursor::new("// should-fail"), None);
+    assert_eq!(d.should_panic, test::ShouldPanic::Yes);
 }
 
 #[test]
@@ -112,10 +123,10 @@ fn no_system_llvm() {
     let mut config = config();
 
     config.system_llvm = false;
-    assert!(!parse_rs(&config, "// no-system-llvm").ignore);
+    assert!(!check_ignore(&config, "// no-system-llvm"));
 
     config.system_llvm = true;
-    assert!(parse_rs(&config, "// no-system-llvm").ignore);
+    assert!(check_ignore(&config, "// no-system-llvm"));
 }
 
 #[test]
@@ -123,16 +134,16 @@ fn llvm_version() {
     let mut config = config();
 
     config.llvm_version = Some(80102);
-    assert!(parse_rs(&config, "// min-llvm-version: 9.0").ignore);
+    assert!(check_ignore(&config, "// min-llvm-version: 9.0"));
 
     config.llvm_version = Some(90001);
-    assert!(parse_rs(&config, "// min-llvm-version: 9.2").ignore);
+    assert!(check_ignore(&config, "// min-llvm-version: 9.2"));
 
     config.llvm_version = Some(90301);
-    assert!(!parse_rs(&config, "// min-llvm-version: 9.2").ignore);
+    assert!(!check_ignore(&config, "// min-llvm-version: 9.2"));
 
     config.llvm_version = Some(100000);
-    assert!(!parse_rs(&config, "// min-llvm-version: 9.0").ignore);
+    assert!(!check_ignore(&config, "// min-llvm-version: 9.0"));
 }
 
 #[test]
@@ -140,16 +151,16 @@ fn ignore_target() {
     let mut config = config();
     config.target = "x86_64-unknown-linux-gnu".to_owned();
 
-    assert!(parse_rs(&config, "// ignore-x86_64-unknown-linux-gnu").ignore);
-    assert!(parse_rs(&config, "// ignore-x86_64").ignore);
-    assert!(parse_rs(&config, "// ignore-linux").ignore);
-    assert!(parse_rs(&config, "// ignore-gnu").ignore);
-    assert!(parse_rs(&config, "// ignore-64bit").ignore);
+    assert!(check_ignore(&config, "// ignore-x86_64-unknown-linux-gnu"));
+    assert!(check_ignore(&config, "// ignore-x86_64"));
+    assert!(check_ignore(&config, "// ignore-linux"));
+    assert!(check_ignore(&config, "// ignore-gnu"));
+    assert!(check_ignore(&config, "// ignore-64bit"));
 
-    assert!(!parse_rs(&config, "// ignore-i686").ignore);
-    assert!(!parse_rs(&config, "// ignore-windows").ignore);
-    assert!(!parse_rs(&config, "// ignore-msvc").ignore);
-    assert!(!parse_rs(&config, "// ignore-32bit").ignore);
+    assert!(!check_ignore(&config, "// ignore-i686"));
+    assert!(!check_ignore(&config, "// ignore-windows"));
+    assert!(!check_ignore(&config, "// ignore-msvc"));
+    assert!(!check_ignore(&config, "// ignore-32bit"));
 }
 
 #[test]
@@ -157,16 +168,16 @@ fn only_target() {
     let mut config = config();
     config.target = "x86_64-pc-windows-gnu".to_owned();
 
-    assert!(parse_rs(&config, "// only-i686").ignore);
-    assert!(parse_rs(&config, "// only-linux").ignore);
-    assert!(parse_rs(&config, "// only-msvc").ignore);
-    assert!(parse_rs(&config, "// only-32bit").ignore);
+    assert!(check_ignore(&config, "// only-i686"));
+    assert!(check_ignore(&config, "// only-linux"));
+    assert!(check_ignore(&config, "// only-msvc"));
+    assert!(check_ignore(&config, "// only-32bit"));
 
-    assert!(!parse_rs(&config, "// only-x86_64-pc-windows-gnu").ignore);
-    assert!(!parse_rs(&config, "// only-x86_64").ignore);
-    assert!(!parse_rs(&config, "// only-windows").ignore);
-    assert!(!parse_rs(&config, "// only-gnu").ignore);
-    assert!(!parse_rs(&config, "// only-64bit").ignore);
+    assert!(!check_ignore(&config, "// only-x86_64-pc-windows-gnu"));
+    assert!(!check_ignore(&config, "// only-x86_64"));
+    assert!(!check_ignore(&config, "// only-windows"));
+    assert!(!check_ignore(&config, "// only-gnu"));
+    assert!(!check_ignore(&config, "// only-64bit"));
 }
 
 #[test]
@@ -174,8 +185,8 @@ fn stage() {
     let mut config = config();
     config.stage_id = "stage1".to_owned();
 
-    assert!(parse_rs(&config, "// ignore-stage1").ignore);
-    assert!(!parse_rs(&config, "// ignore-stage2").ignore);
+    assert!(check_ignore(&config, "// ignore-stage1"));
+    assert!(!check_ignore(&config, "// ignore-stage2"));
 }
 
 #[test]
@@ -183,26 +194,26 @@ fn cross_compile() {
     let mut config = config();
     config.host = "x86_64-apple-darwin".to_owned();
     config.target = "wasm32-unknown-unknown".to_owned();
-    assert!(parse_rs(&config, "// ignore-cross-compile").ignore);
+    assert!(check_ignore(&config, "// ignore-cross-compile"));
 
     config.target = config.host.clone();
-    assert!(!parse_rs(&config, "// ignore-cross-compile").ignore);
+    assert!(!check_ignore(&config, "// ignore-cross-compile"));
 }
 
 #[test]
 fn debugger() {
     let mut config = config();
     config.debugger = None;
-    assert!(!parse_rs(&config, "// ignore-cdb").ignore);
+    assert!(!check_ignore(&config, "// ignore-cdb"));
 
     config.debugger = Some(Debugger::Cdb);
-    assert!(parse_rs(&config, "// ignore-cdb").ignore);
+    assert!(check_ignore(&config, "// ignore-cdb"));
 
     config.debugger = Some(Debugger::Gdb);
-    assert!(parse_rs(&config, "// ignore-gdb").ignore);
+    assert!(check_ignore(&config, "// ignore-gdb"));
 
     config.debugger = Some(Debugger::Lldb);
-    assert!(parse_rs(&config, "// ignore-lldb").ignore);
+    assert!(check_ignore(&config, "// ignore-lldb"));
 }
 
 #[test]
@@ -211,17 +222,17 @@ fn sanitizers() {
 
     // Target that supports all sanitizers:
     config.target = "x86_64-unknown-linux-gnu".to_owned();
-    assert!(!parse_rs(&config, "// needs-sanitizer-address").ignore);
-    assert!(!parse_rs(&config, "// needs-sanitizer-leak").ignore);
-    assert!(!parse_rs(&config, "// needs-sanitizer-memory").ignore);
-    assert!(!parse_rs(&config, "// needs-sanitizer-thread").ignore);
+    assert!(!check_ignore(&config, "// needs-sanitizer-address"));
+    assert!(!check_ignore(&config, "// needs-sanitizer-leak"));
+    assert!(!check_ignore(&config, "// needs-sanitizer-memory"));
+    assert!(!check_ignore(&config, "// needs-sanitizer-thread"));
 
     // Target that doesn't support sanitizers:
     config.target = "wasm32-unknown-emscripten".to_owned();
-    assert!(parse_rs(&config, "// needs-sanitizer-address").ignore);
-    assert!(parse_rs(&config, "// needs-sanitizer-leak").ignore);
-    assert!(parse_rs(&config, "// needs-sanitizer-memory").ignore);
-    assert!(parse_rs(&config, "// needs-sanitizer-thread").ignore);
+    assert!(check_ignore(&config, "// needs-sanitizer-address"));
+    assert!(check_ignore(&config, "// needs-sanitizer-leak"));
+    assert!(check_ignore(&config, "// needs-sanitizer-memory"));
+    assert!(check_ignore(&config, "// needs-sanitizer-thread"));
 }
 
 #[test]
@@ -229,10 +240,10 @@ fn asm_support() {
     let mut config = config();
 
     config.target = "avr-unknown-gnu-atmega328".to_owned();
-    assert!(parse_rs(&config, "// needs-asm-support").ignore);
+    assert!(check_ignore(&config, "// needs-asm-support"));
 
     config.target = "i686-unknown-netbsd".to_owned();
-    assert!(!parse_rs(&config, "// needs-asm-support").ignore);
+    assert!(!check_ignore(&config, "// needs-asm-support"));
 }
 
 #[test]
@@ -240,13 +251,13 @@ fn channel() {
     let mut config = config();
     config.channel = "beta".into();
 
-    assert!(parse_rs(&config, "// ignore-beta").ignore);
-    assert!(parse_rs(&config, "// only-nightly").ignore);
-    assert!(parse_rs(&config, "// only-stable").ignore);
+    assert!(check_ignore(&config, "// ignore-beta"));
+    assert!(check_ignore(&config, "// only-nightly"));
+    assert!(check_ignore(&config, "// only-stable"));
 
-    assert!(!parse_rs(&config, "// only-beta").ignore);
-    assert!(!parse_rs(&config, "// ignore-nightly").ignore);
-    assert!(!parse_rs(&config, "// ignore-stable").ignore);
+    assert!(!check_ignore(&config, "// only-beta"));
+    assert!(!check_ignore(&config, "// ignore-nightly"));
+    assert!(!check_ignore(&config, "// ignore-stable"));
 }
 
 #[test]
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index c854663706a..46432d5e4f5 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -8,7 +8,7 @@ extern crate test;
 use crate::common::{
     expected_output_path, output_base_dir, output_relative_path, PanicStrategy, UI_EXTENSIONS,
 };
-use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, Pretty, TestPaths};
+use crate::common::{CompareMode, Config, Debugger, Mode, PassMode, TestPaths};
 use crate::util::logv;
 use getopts::Options;
 use std::env;
@@ -22,7 +22,7 @@ use test::ColorConfig;
 use tracing::*;
 use walkdir::WalkDir;
 
-use self::header::EarlyProps;
+use self::header::{make_test_description, EarlyProps};
 
 #[cfg(test)]
 mod tests;
@@ -620,26 +620,13 @@ pub fn is_test(file_name: &OsString) -> bool {
 }
 
 fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test::TestDescAndFn> {
-    let early_props = if config.mode == Mode::RunMake {
-        // Allow `ignore` directives to be in the Makefile.
-        EarlyProps::from_file(config, &testpaths.file.join("Makefile"))
+    let test_path = if config.mode == Mode::RunMake {
+        // Parse directives in the Makefile
+        testpaths.file.join("Makefile")
     } else {
-        EarlyProps::from_file(config, &testpaths.file)
-    };
-
-    // The `should-fail` annotation doesn't apply to pretty tests,
-    // since we run the pretty printer across all tests by default.
-    // If desired, we could add a `should-fail-pretty` annotation.
-    let should_panic = match config.mode {
-        Pretty => test::ShouldPanic::No,
-        _ => {
-            if early_props.should_fail {
-                test::ShouldPanic::Yes
-            } else {
-                test::ShouldPanic::No
-            }
-        }
+        PathBuf::from(&testpaths.file)
     };
+    let early_props = EarlyProps::from_file(config, &test_path);
 
     // Incremental tests are special, they inherently cannot be run in parallel.
     // `runtest::run` will be responsible for iterating over revisions.
@@ -651,29 +638,20 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec<test
     revisions
         .into_iter()
         .map(|revision| {
-            let ignore = early_props.ignore
-                // Ignore tests that already run and are up to date with respect to inputs.
-                || is_up_to_date(
-                    config,
-                    testpaths,
-                    &early_props,
-                    revision.map(|s| s.as_str()),
-                    inputs,
-                );
-            test::TestDescAndFn {
-                desc: test::TestDesc {
-                    name: make_test_name(config, testpaths, revision),
-                    ignore,
-                    should_panic,
-                    allow_fail: false,
-                    #[cfg(not(bootstrap))]
-                    compile_fail: false,
-                    #[cfg(not(bootstrap))]
-                    no_run: false,
-                    test_type: test::TestType::Unknown,
-                },
-                testfn: make_test_closure(config, testpaths, revision),
-            }
+            let src_file =
+                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);
+            // Ignore tests that already run and are up to date with respect to inputs.
+            desc.ignore |= is_up_to_date(
+                config,
+                testpaths,
+                &early_props,
+                revision.map(|s| s.as_str()),
+                inputs,
+            );
+            test::TestDescAndFn { desc, testfn: make_test_closure(config, testpaths, revision) }
         })
         .collect()
 }