mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
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:
commit
54d9a67ba5
9
src/test/ui/meta/auxiliary/env.rs
Normal file
9
src/test/ui/meta/auxiliary/env.rs
Normal 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");
|
||||
}
|
@ -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`
|
@ -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() {
|
@ -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
|
18
src/test/ui/meta/rustc-env.rs
Normal file
18
src/test/ui/meta/rustc-env.rs
Normal 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();
|
||||
}
|
Loading…
Reference in New Issue
Block a user