Skip to content

Commit

Permalink
Add ui tests for --env option
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Dec 10, 2023
1 parent 486e55e commit 37d6809
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/ui/extenv/extenv-env-overload.rs
Original file line number Diff line number Diff line change
@@ -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");
}
5 changes: 5 additions & 0 deletions tests/ui/extenv/extenv-env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// compile-flags: --env FOO=123abc -Zunstable-options
// run-pass
fn main() {
assert_eq!(env!("FOO"), "123abc");
}
7 changes: 7 additions & 0 deletions tests/ui/extenv/extenv-not-env.rs
Original file line number Diff line number Diff line change
@@ -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());
}

0 comments on commit 37d6809

Please sign in to comment.