Skip to content

Commit b529e27

Browse files
committed
Auto merge of rust-lang#131044 - EnzymeAD:enzyme-testinfra, r=jieyouxu
add has_enzyme/needs-enzyme to the test infra This unblocks merging the Enzyme / Autodiff frontend. For the full implementation, see: rust-lang#129175 We don't want to run tests that require Enzyme / Autodiff support when we build rustc without the required features. It correctly filtered out a test which started with `//@ needs-enzyme`. ``` running 80 tests i............................................................................... test result: ok. 79 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 380.41ms ``` Tracking: - rust-lang#124509 r? jieyouxu
2 parents 0245b0c + bc2a913 commit b529e27

File tree

6 files changed

+19
-0
lines changed

6 files changed

+19
-0
lines changed

src/bootstrap/src/core/build_steps/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1792,6 +1792,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17921792
cmd.arg("--host").arg(&*compiler.host.triple);
17931793
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));
17941794

1795+
if builder.build.config.llvm_enzyme {
1796+
cmd.arg("--has-enzyme");
1797+
}
1798+
17951799
if builder.config.cmd.bless() {
17961800
cmd.arg("--bless");
17971801
}

src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
139139
"needs-deterministic-layouts",
140140
"needs-dlltool",
141141
"needs-dynamic-linking",
142+
"needs-enzyme",
142143
"needs-force-clang-based-tests",
143144
"needs-git-hash",
144145
"needs-llvm-components",

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ pub struct Config {
349349
/// whether to run `tidy` when a rustdoc test fails
350350
pub has_tidy: bool,
351351

352+
/// whether to run `enzyme` autodiff tests
353+
pub has_enzyme: bool,
354+
352355
/// The current Rust channel
353356
pub channel: String,
354357

src/tools/compiletest/src/header.rs

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ pub struct TestProps {
218218
pub filecheck_flags: Vec<String>,
219219
/// Don't automatically insert any `--check-cfg` args
220220
pub no_auto_check_cfg: bool,
221+
/// Run tests which require enzyme being build
222+
pub has_enzyme: bool,
221223
}
222224

223225
mod directives {
@@ -322,6 +324,7 @@ impl TestProps {
322324
llvm_cov_flags: vec![],
323325
filecheck_flags: vec![],
324326
no_auto_check_cfg: false,
327+
has_enzyme: false,
325328
}
326329
}
327330

src/tools/compiletest/src/header/needs.rs

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ pub(super) fn handle_needs(
7979
condition: cache.sanitizer_safestack,
8080
ignore_reason: "ignored on targets without SafeStack support",
8181
},
82+
Need {
83+
name: "needs-enzyme",
84+
condition: config.has_enzyme,
85+
ignore_reason: "ignored when LLVM Enzyme is disabled",
86+
},
8287
Need {
8388
name: "needs-run-enabled",
8489
condition: config.run_enabled(),

src/tools/compiletest/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
8383
)
8484
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
8585
.optflag("", "ignored", "run tests marked as ignored")
86+
.optflag("", "has-enzyme", "run tests that require enzyme")
8687
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
8788
.optmulti(
8889
"",
@@ -233,6 +234,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
233234
// Avoid spawning an external command when we know tidy won't be used.
234235
false
235236
};
237+
let has_enzyme = matches.opt_present("has-enzyme");
236238
let filters = if mode == Mode::RunMake {
237239
matches
238240
.free
@@ -331,6 +333,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
331333
.map(|s| s.parse().expect("invalid --compare-mode provided")),
332334
rustfix_coverage: matches.opt_present("rustfix-coverage"),
333335
has_tidy,
336+
has_enzyme,
334337
channel: matches.opt_str("channel").unwrap(),
335338
git_hash: matches.opt_present("git-hash"),
336339
edition: matches.opt_str("edition"),

0 commit comments

Comments
 (0)