File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ // Check that changes to environment variables are propagated to `env!`.
2+ //
3+ // This test is intentionally written to not use any `#[cfg(rpass*)]`, to
4+ // _really_ test that we re-compile if the environment variable changes.
5+
6+ //@ revisions: cfail1 rpass2 rpass3 cfail4
7+ //@ [cfail1]unset-rustc-env:EXAMPLE_ENV
8+ //@ [rpass2]rustc-env:EXAMPLE_ENV=one
9+ //@ [rpass2]exec-env:EXAMPLE_ENV=one
10+ //@ [rpass3]rustc-env:EXAMPLE_ENV=two
11+ //@ [rpass3]exec-env:EXAMPLE_ENV=two
12+ //@ [cfail4]unset-rustc-env:EXAMPLE_ENV
13+
14+ fn main ( ) {
15+ assert_eq ! ( env!( "EXAMPLE_ENV" ) , std:: env:: var( "EXAMPLE_ENV" ) . unwrap( ) ) ;
16+ //[cfail1]~^ ERROR environment variable `EXAMPLE_ENV` not defined at compile time
17+ //[cfail4]~^^ ERROR environment variable `EXAMPLE_ENV` not defined at compile time
18+ }
Original file line number Diff line number Diff line change 1+ // Check that changes to environment variables are propagated to `option_env!`.
2+ //
3+ // This test is intentionally written to not use any `#[cfg(rpass*)]`, to
4+ // _really_ test that we re-compile if the environment variable changes.
5+
6+ //@ revisions: rpass1 rpass2 rpass3 rpass4
7+ //@ [rpass1]unset-rustc-env:EXAMPLE_ENV
8+ //@ [rpass1]unset-exec-env:EXAMPLE_ENV
9+ //@ [rpass2]rustc-env:EXAMPLE_ENV=one
10+ //@ [rpass2]exec-env:EXAMPLE_ENV=one
11+ //@ [rpass3]rustc-env:EXAMPLE_ENV=two
12+ //@ [rpass3]exec-env:EXAMPLE_ENV=two
13+ //@ [rpass4]unset-rustc-env:EXAMPLE_ENV
14+ //@ [rpass4]unset-exec-env:EXAMPLE_ENV
15+
16+ fn main ( ) {
17+ assert_eq ! ( option_env!( "EXAMPLE_ENV" ) , std:: env:: var( "EXAMPLE_ENV" ) . ok( ) . as_deref( ) ) ;
18+ }
You can’t perform that action at this time.
0 commit comments