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

compiletest: Deduplicate --check-prefix flags #134415

Closed
wants to merge 1 commit into from
Closed
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
15 changes: 11 additions & 4 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::ffi::{OsStr, OsString};
use std::fs::{self, File, create_dir_all};
use std::hash::{DefaultHasher, Hash, Hasher};
Expand Down Expand Up @@ -1962,16 +1962,18 @@ impl<'test> TestCx<'test> {
// via `filecheck-flags` or by adding new header directives.

// Because we use custom prefixes, we also have to register the default prefix.
filecheck.arg("--check-prefix=CHECK");
// Deduplicate these in a set so revisions like `CHECK`, `MSVC`, and `NONMSVC` don't
// cause errors.
let mut check_prefixes = BTreeSet::from(["CHECK"]);

// Some tests use the current revision name as a check prefix.
if let Some(rev) = self.revision {
filecheck.arg("--check-prefix").arg(rev);
check_prefixes.insert(rev);
}

// Some tests also expect either the MSVC or NONMSVC prefix to be defined.
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
filecheck.arg("--check-prefix").arg(msvc_or_not);
check_prefixes.insert(msvc_or_not);

// The filecheck tool normally fails if a prefix is defined but not used.
// However, we define several prefixes globally for all tests.
Expand All @@ -1983,6 +1985,11 @@ impl<'test> TestCx<'test> {
// Add custom flags supplied by the `filecheck-flags:` test header.
filecheck.args(&self.props.filecheck_flags);

for prefix in check_prefixes {
// Set the expected prefixes
filecheck.arg("--check-prefix").arg(prefix);
}

self.compose_and_run(filecheck, "", None, None)
}

Expand Down
Loading