This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-0
lines changed
doc/rustc-dev-guide/src/tests Expand file tree Collapse file tree 4 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,7 @@ settings:
158158
159159- ` needs-asm-support ` — ignores if it is running on a target that doesn't have
160160 stable support for ` asm! `
161+ - ` needs-env-vars ` - ignores if the target doesn't support environment variables
161162- ` needs-profiler-runtime ` — ignores the test if the profiler runtime was not
162163 enabled for the target
163164 (` build.profiler = true ` in rustc's ` bootstrap.toml ` )
Original file line number Diff line number Diff line change @@ -520,6 +520,16 @@ impl Config {
520520 || self . target_cfg ( ) . os == "emscripten" ;
521521 !unsupported_target
522522 }
523+
524+ pub fn has_env_vars ( & self ) -> bool {
525+ // As with some of the other target properties, we don't have a principled
526+ // way to know whether the target supports environment variables, so we
527+ // just hard-code a reasonable approximation.
528+
529+ let target = self . target_cfg ( ) ;
530+ let no_env = matches ! ( target. arch. as_str( ) , "wasm32" | "wasm64" ) && target. os == "unknown" ;
531+ !no_env
532+ }
523533}
524534
525535/// Known widths of `target_has_atomic`.
Original file line number Diff line number Diff line change @@ -135,6 +135,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
135135 "needs-deterministic-layouts" ,
136136 "needs-dlltool" ,
137137 "needs-dynamic-linking" ,
138+ "needs-env-vars" ,
138139 "needs-enzyme" ,
139140 "needs-force-clang-based-tests" ,
140141 "needs-git-hash" ,
Original file line number Diff line number Diff line change @@ -174,6 +174,11 @@ pub(super) fn handle_needs(
174174 condition : config. with_std_debug_assertions ,
175175 ignore_reason : "ignored if std wasn't built with debug assertions" ,
176176 } ,
177+ Need {
178+ name : "needs-env-vars" ,
179+ condition : config. has_env_vars ( ) ,
180+ ignore_reason : "ignored on targets without environment variables" ,
181+ } ,
177182 ] ;
178183
179184 let ( name, rest) = match ln. split_once ( [ ':' , ' ' ] ) {
You can’t perform that action at this time.
0 commit comments