Skip to content

Commit 8069e25

Browse files
lqdKobzol
authored andcommitted
add optional build components for the test environment
1 parent 6a689bd commit 8069e25

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/tools/opt-dist/src/environment.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ pub struct Environment {
2727
shared_llvm: bool,
2828
run_tests: bool,
2929
fast_try_build: bool,
30+
/// Additional configuration that bootstrap needs to know only when running tests.
31+
#[builder(default)]
32+
test_config: TestConfig,
33+
}
34+
35+
/// Builds have optional components, and their presence/absence can enable/disable a subset of
36+
/// tests. When testing the optimized artifacts, bootstrap needs to know about these enabled
37+
/// components to run the expected subset. This structure holds the known components where this
38+
/// matters: currently only whether the build to test is using debug assertions.
39+
///
40+
/// FIXME: ultimately, this is a temporary band-aid, and opt-dist should be more transparent to the
41+
/// CI config and bootstrap optional components: bootstrap has default values, combinations of flags
42+
/// that cascade into others, etc logic that we'd have to duplicate here otherwise. It's more
43+
/// sensible for opt-dist to never know about the config apart from the minimal set of paths
44+
/// required to configure stage0 tests.
45+
#[derive(Builder, Default, Clone, Debug)]
46+
pub struct TestConfig {
47+
/// Whether the build under test is explicitly using `--enable-debug-assertions`.
48+
/// Note that this flag can be implied from others, like `rust.debug`, and we do not handle any
49+
/// of these subtleties and defaults here, as per the FIXME above.
50+
pub enable_debug_assertions: bool,
3051
}
3152

3253
impl Environment {
@@ -111,6 +132,21 @@ impl Environment {
111132
pub fn is_fast_try_build(&self) -> bool {
112133
self.fast_try_build
113134
}
135+
136+
pub fn test_config(&self) -> &TestConfig {
137+
&self.test_config
138+
}
139+
}
140+
141+
impl TestConfig {
142+
/// Returns the test config matching the given `RUST_CONFIGURE_ARGS` for the known optional
143+
/// components for tests. This is obviously extremely fragile and we'd rather opt-dist not
144+
/// handle any optional components.
145+
pub fn from_configure_args(configure_args: &str) -> TestConfig {
146+
let enable_debug_assertions =
147+
configure_args.split(" ").find(|part| *part == "--enable-debug-assertions").is_some();
148+
TestConfig { enable_debug_assertions }
149+
}
114150
}
115151

116152
/// What is the extension of binary executables on this platform?

0 commit comments

Comments
 (0)