File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed
tests/run-make/fmt-write-bloat Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,19 @@ impl TestCx<'_> {
225
225
cmd. env ( "RUNNER" , runner) ;
226
226
}
227
227
228
+ // Guard against externally-set env vars.
229
+ cmd. env_remove ( "__RUSTC_DEBUG_ASSERTIONS_ENABLED" ) ;
230
+ if self . config . with_rustc_debug_assertions {
231
+ // Used for `run_make_support::env::rustc_debug_assertions_enabled`.
232
+ cmd. env ( "__RUSTC_DEBUG_ASSERTIONS_ENABLED" , "1" ) ;
233
+ }
234
+
235
+ cmd. env_remove ( "__STD_DEBUG_ASSERTIONS_ENABLED" ) ;
236
+ if self . config . with_std_debug_assertions {
237
+ // Used for `run_make_support::env::std_debug_assertions_enabled`.
238
+ cmd. env ( "__STD_DEBUG_ASSERTIONS_ENABLED" , "1" ) ;
239
+ }
240
+
228
241
// We don't want RUSTFLAGS set from the outside to interfere with
229
242
// compiler flags set in the test cases:
230
243
cmd. env_remove ( "RUSTFLAGS" ) ;
Original file line number Diff line number Diff line change @@ -18,11 +18,20 @@ pub fn env_var_os(name: &str) -> OsString {
18
18
}
19
19
}
20
20
21
- /// Check if `NO_DEBUG_ASSERTIONS` is set (usually this may be set in CI jobs) .
21
+ /// Check if staged `rustc`-under-test was built with debug assertions .
22
22
#[ track_caller]
23
23
#[ must_use]
24
- pub fn no_debug_assertions ( ) -> bool {
25
- std:: env:: var_os ( "NO_DEBUG_ASSERTIONS" ) . is_some ( )
24
+ pub fn rustc_debug_assertions_enabled ( ) -> bool {
25
+ // Note: we assume this env var is set when the test recipe is being executed.
26
+ std:: env:: var_os ( "__RUSTC_DEBUG_ASSERTIONS_ENABLED" ) . is_some ( )
27
+ }
28
+
29
+ /// Check if staged `std`-under-test was built with debug assertions.
30
+ #[ track_caller]
31
+ #[ must_use]
32
+ pub fn std_debug_assertions_enabled ( ) -> bool {
33
+ // Note: we assume this env var is set when the test recipe is being executed.
34
+ std:: env:: var_os ( "__STD_DEBUG_ASSERTIONS_ENABLED" ) . is_some ( )
26
35
}
27
36
28
37
/// A wrapper around [`std::env::set_current_dir`] which includes the directory
Original file line number Diff line number Diff line change 18
18
//@ ignore-cross-compile
19
19
20
20
use run_make_support:: artifact_names:: bin_name;
21
- use run_make_support:: env:: no_debug_assertions ;
21
+ use run_make_support:: env:: std_debug_assertions_enabled ;
22
22
use run_make_support:: rustc;
23
23
use run_make_support:: symbols:: any_symbol_contains;
24
24
25
25
fn main ( ) {
26
26
rustc ( ) . input ( "main.rs" ) . opt ( ) . run ( ) ;
27
27
// panic machinery identifiers, these should not appear in the final binary
28
28
let mut panic_syms = vec ! [ "panic_bounds_check" , "Debug" ] ;
29
- if no_debug_assertions ( ) {
29
+ if std_debug_assertions_enabled ( ) {
30
30
// if debug assertions are allowed, we need to allow these,
31
31
// otherwise, add them to the list of symbols to deny.
32
32
panic_syms. extend_from_slice ( & [ "panicking" , "panic_fmt" , "pad_integral" , "Display" ] ) ;
You can’t perform that action at this time.
0 commit comments