Test that env! works with incremental compilation
This currently works because it's part of expansion, and that isn't yet tracked by the query system. But we want to ensure it continues working, even if that is changed.
This commit is contained in:
parent
65899c06f1
commit
c772573708
2 changed files with 36 additions and 0 deletions
18
tests/incremental/env/env_macro.rs
vendored
Normal file
18
tests/incremental/env/env_macro.rs
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Check that changes to environment variables are propagated to `env!`.
|
||||
//
|
||||
// This test is intentionally written to not use any `#[cfg(rpass*)]`, to
|
||||
// _really_ test that we re-compile if the environment variable changes.
|
||||
|
||||
//@ revisions: cfail1 rpass2 rpass3 cfail4
|
||||
//@ [cfail1]unset-rustc-env:EXAMPLE_ENV
|
||||
//@ [rpass2]rustc-env:EXAMPLE_ENV=one
|
||||
//@ [rpass2]exec-env:EXAMPLE_ENV=one
|
||||
//@ [rpass3]rustc-env:EXAMPLE_ENV=two
|
||||
//@ [rpass3]exec-env:EXAMPLE_ENV=two
|
||||
//@ [cfail4]unset-rustc-env:EXAMPLE_ENV
|
||||
|
||||
fn main() {
|
||||
assert_eq!(env!("EXAMPLE_ENV"), std::env::var("EXAMPLE_ENV").unwrap());
|
||||
//[cfail1]~^ ERROR environment variable `EXAMPLE_ENV` not defined at compile time
|
||||
//[cfail4]~^^ ERROR environment variable `EXAMPLE_ENV` not defined at compile time
|
||||
}
|
||||
18
tests/incremental/env/option_env_macro.rs
vendored
Normal file
18
tests/incremental/env/option_env_macro.rs
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Check that changes to environment variables are propagated to `option_env!`.
|
||||
//
|
||||
// This test is intentionally written to not use any `#[cfg(rpass*)]`, to
|
||||
// _really_ test that we re-compile if the environment variable changes.
|
||||
|
||||
//@ revisions: rpass1 rpass2 rpass3 rpass4
|
||||
//@ [rpass1]unset-rustc-env:EXAMPLE_ENV
|
||||
//@ [rpass1]unset-exec-env:EXAMPLE_ENV
|
||||
//@ [rpass2]rustc-env:EXAMPLE_ENV=one
|
||||
//@ [rpass2]exec-env:EXAMPLE_ENV=one
|
||||
//@ [rpass3]rustc-env:EXAMPLE_ENV=two
|
||||
//@ [rpass3]exec-env:EXAMPLE_ENV=two
|
||||
//@ [rpass4]unset-rustc-env:EXAMPLE_ENV
|
||||
//@ [rpass4]unset-exec-env:EXAMPLE_ENV
|
||||
|
||||
fn main() {
|
||||
assert_eq!(option_env!("EXAMPLE_ENV"), std::env::var("EXAMPLE_ENV").ok().as_deref());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue