Skip to content

Commit 6b49c26

Browse files
committed
add optional build components for the test environment
1 parent d56fa5d commit 6b49c26

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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

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

3051
impl Environment {
@@ -101,6 +122,21 @@ impl Environment {
101122
pub fn benchmark_cargo_config(&self) -> &[String] {
102123
&self.benchmark_cargo_config
103124
}
125+
126+
pub fn test_config(&self) -> &TestConfig {
127+
&self.test_config
128+
}
129+
}
130+
131+
impl TestConfig {
132+
/// Returns the test config matching the given `RUST_CONFIGURE_ARGS` for the known optional
133+
/// components for tests. This is obviously extremely fragile and we'd rather opt-dist not
134+
/// handle any optional components.
135+
pub fn from_configure_args(configure_args: &str) -> TestConfig {
136+
let enable_debug_assertions =
137+
configure_args.split(" ").find(|part| *part == "--enable-debug-assertions").is_some();
138+
TestConfig { enable_debug_assertions }
139+
}
104140
}
105141

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

0 commit comments

Comments
 (0)