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<'_> {
225225 cmd. env ( "RUNNER" , runner) ;
226226 }
227227
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+
228241 // We don't want RUSTFLAGS set from the outside to interfere with
229242 // compiler flags set in the test cases:
230243 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 {
1818 }
1919}
2020
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 .
2222#[ track_caller]
2323#[ 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 ( )
2635}
2736
2837/// A wrapper around [`std::env::set_current_dir`] which includes the directory
Original file line number Diff line number Diff line change 1818//@ ignore-cross-compile
1919
2020use 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 ;
2222use run_make_support:: rustc;
2323use run_make_support:: symbols:: any_symbol_contains;
2424
2525fn main ( ) {
2626 rustc ( ) . input ( "main.rs" ) . opt ( ) . run ( ) ;
2727 // panic machinery identifiers, these should not appear in the final binary
2828 let mut panic_syms = vec ! [ "panic_bounds_check" , "Debug" ] ;
29- if no_debug_assertions ( ) {
29+ if std_debug_assertions_enabled ( ) {
3030 // if debug assertions are allowed, we need to allow these,
3131 // otherwise, add them to the list of symbols to deny.
3232 panic_syms. extend_from_slice ( & [ "panicking" , "panic_fmt" , "pad_integral" , "Display" ] ) ;
You can’t perform that action at this time.
0 commit comments