Rollup merge of #78575 - tmiasko:compiletest-rustc-env, r=Aaron1011

Add a test for compiletest rustc-env & unset-rustc-env directives

... and move compiletest meta tests into a separate directory.
This commit is contained in:
Yuki Okushi 2020-11-03 15:27:11 +09:00 committed by GitHub
commit 54d9a67ba5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 3 deletions

View File

@ -0,0 +1,9 @@
// Check that aux builds can also use rustc-env, but environment is configured
// separately from the main test case.
//
// rustc-env:COMPILETEST_BAR=bar
pub fn test() {
assert_eq!(option_env!("COMPILETEST_FOO"), None);
assert_eq!(env!("COMPILETEST_BAR"), "bar");
}

View File

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/meta-expected-error-correct-rev.rs:7:18
--> $DIR/expected-error-correct-rev.rs:7:18
|
LL | let x: u32 = 22_usize;
| --- ^^^^^^^^ expected `u32`, found `usize`

View File

@ -1,6 +1,6 @@
// revisions: a
// Counterpart to `meta-expected-error-wrong-rev.rs`
// Counterpart to `expected-error-wrong-rev.rs`
#[cfg(a)]
fn foo() {

View File

@ -1,5 +1,5 @@
// Meta test for compiletest: check that when we give the right error
// patterns, the test passes. See all `meta-revision-bad.rs`.
// patterns, the test passes. See all `revision-bad.rs`.
// run-fail
// revisions: foo bar

View File

@ -0,0 +1,18 @@
// Compiletest meta test checking that rustc-env and unset-rustc-env directives
// can be used to configure environment for rustc.
//
// run-pass
// aux-build:env.rs
// rustc-env:COMPILETEST_FOO=foo
//
// An environment variable that is likely to be set, but should be safe to unset.
// unset-rustc-env:PWD
extern crate env;
fn main() {
assert_eq!(env!("COMPILETEST_FOO"), "foo");
assert_eq!(option_env!("COMPILETEST_BAR"), None);
assert_eq!(option_env!("PWD"), None);
env::test();
}