File tree Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Expand file tree Collapse file tree 3 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -340,10 +340,12 @@ impl<'cfg> Compilation<'cfg> {
340
340
. env ( "CARGO_PKG_AUTHORS" , & pkg. authors ( ) . join ( ":" ) )
341
341
. cwd ( pkg. root ( ) ) ;
342
342
343
- // Apply any environment variables from the config
344
- for ( key, value) in self . config . env_config ( ) ?. iter ( ) {
345
- if value. is_force ( ) || cmd. get_env ( & key) . is_none ( ) {
346
- cmd. env ( & key, value. resolve ( & self . config ) ) ;
343
+ if self . config . cli_unstable ( ) . configurable_env {
344
+ // Apply any environment variables from the config
345
+ for ( key, value) in self . config . env_config ( ) ?. iter ( ) {
346
+ if value. is_force ( ) || cmd. get_env ( & key) . is_none ( ) {
347
+ cmd. env ( & key, value. resolve ( & self . config ) ) ;
348
+ }
347
349
}
348
350
}
349
351
Original file line number Diff line number Diff line change @@ -444,6 +444,7 @@ pub struct CliUnstable {
444
444
pub weak_dep_features : bool ,
445
445
pub extra_link_arg : bool ,
446
446
pub credential_process : bool ,
447
+ pub configurable_env : bool ,
447
448
}
448
449
449
450
const STABILIZED_COMPILE_PROGRESS : & str = "The progress bar is now always \
@@ -598,6 +599,7 @@ impl CliUnstable {
598
599
"doctest-xcompile" => self . doctest_xcompile = parse_empty ( k, v) ?,
599
600
"panic-abort-tests" => self . panic_abort_tests = parse_empty ( k, v) ?,
600
601
"jobserver-per-rustc" => self . jobserver_per_rustc = parse_empty ( k, v) ?,
602
+ "configurable-env" => self . configurable_env = parse_empty ( k, v) ?,
601
603
"features" => {
602
604
// For now this is still allowed (there are still some
603
605
// unstable options like "compare"). This should be removed at
Original file line number Diff line number Diff line change @@ -25,7 +25,8 @@ fn env_basic() {
25
25
)
26
26
. build ( ) ;
27
27
28
- p. cargo ( "run" )
28
+ p. cargo ( "run -Zconfigurable-env" )
29
+ . masquerade_as_nightly_cargo ( )
29
30
. with_stdout_contains ( "compile-time:Hello" )
30
31
. with_stdout_contains ( "run-time:Hello" )
31
32
. run ( ) ;
@@ -51,7 +52,8 @@ fn env_invalid() {
51
52
)
52
53
. build ( ) ;
53
54
54
- p. cargo ( "build" )
55
+ p. cargo ( "build -Zconfigurable-env" )
56
+ . masquerade_as_nightly_cargo ( )
55
57
. with_status ( 101 )
56
58
. with_stderr_contains ( "[..]`env.ENV_TEST_BOOL` expected a string, but found a boolean" )
57
59
. run ( ) ;
@@ -81,7 +83,8 @@ fn env_force() {
81
83
)
82
84
. build ( ) ;
83
85
84
- p. cargo ( "run" )
86
+ p. cargo ( "run -Zconfigurable-env" )
87
+ . masquerade_as_nightly_cargo ( )
85
88
. env ( "ENV_TEST_FORCED" , "from-env" )
86
89
. env ( "ENV_TEST_UNFORCED" , "from-env" )
87
90
. with_stdout_contains ( "ENV_TEST_FORCED:from-config" )
@@ -117,5 +120,7 @@ fn env_relative() {
117
120
)
118
121
. build ( ) ;
119
122
120
- p. cargo ( "run" ) . run ( ) ;
123
+ p. cargo ( "run -Zconfigurable-env" )
124
+ . masquerade_as_nightly_cargo ( )
125
+ . run ( ) ;
121
126
}
You can’t perform that action at this time.
0 commit comments