Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add has_enzyme/needs-enzyme to the test infra #131044

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,10 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--host").arg(&*compiler.host.triple);
cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.build));

if builder.build.config.llvm_enzyme {
cmd.arg("--has-enzyme");
}

if builder.config.cmd.bless() {
cmd.arg("--bless");
}
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-deterministic-layouts",
"needs-dlltool",
"needs-dynamic-linking",
"needs-enzyme",
"needs-force-clang-based-tests",
"needs-git-hash",
"needs-llvm-components",
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ pub struct Config {
/// whether to run `tidy` when a rustdoc test fails
pub has_tidy: bool,

/// whether to run `enzyme` autodiff tests
pub has_enzyme: bool,

/// The current Rust channel
pub channel: String,

Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ pub struct TestProps {
pub filecheck_flags: Vec<String>,
/// Don't automatically insert any `--check-cfg` args
pub no_auto_check_cfg: bool,
/// Run tests which require enzyme being build
pub has_enzyme: bool,
}

mod directives {
Expand Down Expand Up @@ -322,6 +324,7 @@ impl TestProps {
llvm_cov_flags: vec![],
filecheck_flags: vec![],
no_auto_check_cfg: false,
has_enzyme: false,
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/tools/compiletest/src/header/needs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ pub(super) fn handle_needs(
condition: cache.sanitizer_safestack,
ignore_reason: "ignored on targets without SafeStack support",
},
Need {
name: "needs-enzyme",
condition: config.has_enzyme,
ignore_reason: "ignored when LLVM Enzyme is disabled",
},
Need {
name: "needs-run-enabled",
condition: config.run_enabled(),
Expand Down
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
)
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
.optflag("", "ignored", "run tests marked as ignored")
.optflag("", "has-enzyme", "run tests that require enzyme")
.optflag("", "with-debug-assertions", "whether to run tests with `ignore-debug` header")
.optmulti(
"",
Expand Down Expand Up @@ -233,6 +234,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
// Avoid spawning an external command when we know tidy won't be used.
false
};
let has_enzyme = matches.opt_present("has-enzyme");
let filters = if mode == Mode::RunMake {
matches
.free
Expand Down Expand Up @@ -331,6 +333,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
.map(|s| s.parse().expect("invalid --compare-mode provided")),
rustfix_coverage: matches.opt_present("rustfix-coverage"),
has_tidy,
has_enzyme,
channel: matches.opt_str("channel").unwrap(),
git_hash: matches.opt_present("git-hash"),
edition: matches.opt_str("edition"),
Expand Down
Loading