Skip to content

Commit c2cd0a9

Browse files
committed
compiletest: Deduplicate --check-prefix flags
Currently having a revision named like `MSVC` causes errors because it gets passed via `--check-prefix` twice; once from the revision name and once from the default `msvc_or_not` value that compiletest sets. Fix this by deduplicating revision names before passing the arguments.
1 parent 82fece9 commit c2cd0a9

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/tools/compiletest/src/runtest.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::borrow::Cow;
2-
use std::collections::{HashMap, HashSet};
2+
use std::collections::{BTreeSet, HashMap, HashSet};
33
use std::ffi::{OsStr, OsString};
44
use std::fs::{self, File, create_dir_all};
55
use std::hash::{DefaultHasher, Hash, Hasher};
@@ -1962,16 +1962,18 @@ impl<'test> TestCx<'test> {
19621962
// via `filecheck-flags` or by adding new header directives.
19631963

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

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

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

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

1988+
for prefix in check_prefixes {
1989+
// Set the expected prefixes
1990+
filecheck.arg("--check-prefix").arg(prefix);
1991+
}
1992+
19861993
self.compose_and_run(filecheck, "", None, None)
19871994
}
19881995

0 commit comments

Comments
 (0)