diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-11-27 13:47:43 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2023-12-10 14:25:57 +0100 |
| commit | 37d68093da7c3b35d5516d3cbe966b2c0d0d17c2 (patch) | |
| tree | 20f4c270905ecd93de60f3225f99dd6c4da56d4a | |
| parent | 486e55e547b8b5a9389ea62642a483e907ede495 (diff) | |
| download | rust-37d68093da7c3b35d5516d3cbe966b2c0d0d17c2.tar.gz rust-37d68093da7c3b35d5516d3cbe966b2c0d0d17c2.zip | |
Add ui tests for `--env` option
| -rw-r--r-- | tests/ui/extenv/extenv-env-overload.rs | 9 | ||||
| -rw-r--r-- | tests/ui/extenv/extenv-env.rs | 5 | ||||
| -rw-r--r-- | tests/ui/extenv/extenv-not-env.rs | 7 |
3 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/extenv/extenv-env-overload.rs b/tests/ui/extenv/extenv-env-overload.rs new file mode 100644 index 00000000000..b82bb2fe966 --- /dev/null +++ b/tests/ui/extenv/extenv-env-overload.rs @@ -0,0 +1,9 @@ +// run-pass +// rustc-env:MY_VAR=tadam +// compile-flags: --env MY_VAR=123abc -Zunstable-options + +// This test ensures that variables provided with `--env` take precedence over +// variables from environment. +fn main() { + assert_eq!(env!("MY_VAR"), "123abc"); +} diff --git a/tests/ui/extenv/extenv-env.rs b/tests/ui/extenv/extenv-env.rs new file mode 100644 index 00000000000..9fda52b8941 --- /dev/null +++ b/tests/ui/extenv/extenv-env.rs @@ -0,0 +1,5 @@ +// compile-flags: --env FOO=123abc -Zunstable-options +// run-pass +fn main() { + assert_eq!(env!("FOO"), "123abc"); +} diff --git a/tests/ui/extenv/extenv-not-env.rs b/tests/ui/extenv/extenv-not-env.rs new file mode 100644 index 00000000000..d6c4a43b003 --- /dev/null +++ b/tests/ui/extenv/extenv-not-env.rs @@ -0,0 +1,7 @@ +// run-pass +// rustc-env:MY_ENV=/ +// Ensures that variables not defined through `--env` are still available. + +fn main() { + assert!(!env!("MY_ENV").is_empty()); +} |
