Skip to content

Commit

Permalink
Rollup merge of rust-lang#78575 - tmiasko:compiletest-rustc-env, r=Aa…
Browse files Browse the repository at this point in the history
…ron1011

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

... and move compiletest meta tests into a separate directory.
  • Loading branch information
Dylan-DPC authored Nov 3, 2020
2 parents 01e7c01 + affb47f commit 5f0c9c1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/test/ui/meta/auxiliary/env.rs
Original file line number Diff line number Diff line change
@@ -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");
}
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/test/ui/meta/rustc-env.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 5f0c9c1

Please sign in to comment.