Skip to content

Commit d5bc586

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 0b63586 commit d5bc586

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::OsString;
44
use std::fs::{self, File, create_dir_all};
55
use std::hash::{DefaultHasher, Hash, Hasher};
@@ -1939,16 +1939,18 @@ impl<'test> TestCx<'test> {
19391939
// via `filecheck-flags` or by adding new header directives.
19401940

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

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

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

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

1965+
for prefix in check_prefixes {
1966+
// Set the expected prefixes
1967+
filecheck.arg("--check-prefix").arg(prefix);
1968+
}
1969+
19631970
self.compose_and_run(filecheck, "", None, None)
19641971
}
19651972

0 commit comments

Comments
 (0)