Skip to content

Commit bbde1c0

Browse files
authored
Rollup merge of #149470 - Zalathar:prepared-conditions, r=jieyouxu
compiletest: Prepare ignore/only conditions once in advance, without a macro Compiletest has historically handled `ignore-*` and `only-*` directives in an extremely confusing way that makes the code hard to understand and hard to modify. This PR therefore takes an important step away from that older design by instead evaluating a set of named boolean "conditions" in advance, and then using those conditions to help determine whether a particular directive should cause its test to be ignored or not. As usual, there's more cleanup that I want to do here, but I've left most of it for future work to help keep this PR manageable. r? jieyouxu
2 parents c539f3f + b03a655 commit bbde1c0

File tree

4 files changed

+248
-309
lines changed

4 files changed

+248
-309
lines changed

src/tools/compiletest/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ doctest = false
99
[[bin]]
1010
name = "compiletest"
1111
path = "src/bin/main.rs"
12+
# The compiletest binary crate is a tiny stub that shouldn't contain any unit
13+
# tests of its own; all of the logic is in the library crate.
14+
test = false
1215

1316
[dependencies]
1417
# tidy-alphabetical-start

src/tools/compiletest/src/directives.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ mod needs;
3434
mod tests;
3535

3636
pub struct DirectivesCache {
37+
/// "Conditions" used by `ignore-*` and `only-*` directives, prepared in
38+
/// advance so that they don't have to be evaluated repeatedly.
39+
cfg_conditions: cfg::PreparedConditions,
3740
needs: CachedNeedsConditions,
3841
}
3942

4043
impl DirectivesCache {
4144
pub fn load(config: &Config) -> Self {
42-
Self { needs: CachedNeedsConditions::load(config) }
45+
Self {
46+
cfg_conditions: cfg::prepare_conditions(config),
47+
needs: CachedNeedsConditions::load(config),
48+
}
4349
}
4450
}
4551

@@ -1058,8 +1064,8 @@ pub(crate) fn make_test_description(
10581064
};
10591065
}
10601066

1061-
decision!(cfg::handle_ignore(config, ln));
1062-
decision!(cfg::handle_only(config, ln));
1067+
decision!(cfg::handle_ignore(&cache.cfg_conditions, ln));
1068+
decision!(cfg::handle_only(&cache.cfg_conditions, ln));
10631069
decision!(needs::handle_needs(&cache.needs, config, ln));
10641070
decision!(ignore_llvm(config, ln));
10651071
decision!(ignore_backends(config, ln));

0 commit comments

Comments
 (0)