Skip to content

Commit affb47f

Browse files
committed
Add a test for compiletest rustc-env & unset-rustc-env directives
1 parent ad27894 commit affb47f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/test/ui/meta/auxiliary/env.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Check that aux builds can also use rustc-env, but environment is configured
2+
// separately from the main test case.
3+
//
4+
// rustc-env:COMPILETEST_BAR=bar
5+
6+
pub fn test() {
7+
assert_eq!(option_env!("COMPILETEST_FOO"), None);
8+
assert_eq!(env!("COMPILETEST_BAR"), "bar");
9+
}

src/test/ui/meta/rustc-env.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Compiletest meta test checking that rustc-env and unset-rustc-env directives
2+
// can be used to configure environment for rustc.
3+
//
4+
// run-pass
5+
// aux-build:env.rs
6+
// rustc-env:COMPILETEST_FOO=foo
7+
//
8+
// An environment variable that is likely to be set, but should be safe to unset.
9+
// unset-rustc-env:PWD
10+
11+
extern crate env;
12+
13+
fn main() {
14+
assert_eq!(env!("COMPILETEST_FOO"), "foo");
15+
assert_eq!(option_env!("COMPILETEST_BAR"), None);
16+
assert_eq!(option_env!("PWD"), None);
17+
env::test();
18+
}

0 commit comments

Comments
 (0)