From ad278943ada85b8c283423e7ef21a7e28a6a1ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 30 Oct 2020 00:00:00 +0000 Subject: [PATCH 1/2] Move compiletest meta tests to a separate directory --- .../expected-error-correct-rev.a.stderr} | 2 +- .../expected-error-correct-rev.rs} | 2 +- src/test/ui/{meta-revision-bad.rs => meta/revision-bad.rs} | 0 src/test/ui/{meta-revision-ok.rs => meta/revision-ok.rs} | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/test/ui/{meta-expected-error-correct-rev.a.stderr => meta/expected-error-correct-rev.a.stderr} (89%) rename src/test/ui/{meta-expected-error-correct-rev.rs => meta/expected-error-correct-rev.rs} (68%) rename src/test/ui/{meta-revision-bad.rs => meta/revision-bad.rs} (100%) rename src/test/ui/{meta-revision-ok.rs => meta/revision-ok.rs} (83%) diff --git a/src/test/ui/meta-expected-error-correct-rev.a.stderr b/src/test/ui/meta/expected-error-correct-rev.a.stderr similarity index 89% rename from src/test/ui/meta-expected-error-correct-rev.a.stderr rename to src/test/ui/meta/expected-error-correct-rev.a.stderr index 5e6980a9dd1f7..df4dbdbc8e62d 100644 --- a/src/test/ui/meta-expected-error-correct-rev.a.stderr +++ b/src/test/ui/meta/expected-error-correct-rev.a.stderr @@ -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` diff --git a/src/test/ui/meta-expected-error-correct-rev.rs b/src/test/ui/meta/expected-error-correct-rev.rs similarity index 68% rename from src/test/ui/meta-expected-error-correct-rev.rs rename to src/test/ui/meta/expected-error-correct-rev.rs index b06a64b15c87c..26798c3dfc29f 100644 --- a/src/test/ui/meta-expected-error-correct-rev.rs +++ b/src/test/ui/meta/expected-error-correct-rev.rs @@ -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() { diff --git a/src/test/ui/meta-revision-bad.rs b/src/test/ui/meta/revision-bad.rs similarity index 100% rename from src/test/ui/meta-revision-bad.rs rename to src/test/ui/meta/revision-bad.rs diff --git a/src/test/ui/meta-revision-ok.rs b/src/test/ui/meta/revision-ok.rs similarity index 83% rename from src/test/ui/meta-revision-ok.rs rename to src/test/ui/meta/revision-ok.rs index 7df9a6ea48fae..bbeae41b8bb95 100644 --- a/src/test/ui/meta-revision-ok.rs +++ b/src/test/ui/meta/revision-ok.rs @@ -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 From affb47fa5750bae1adfbbcf8032bb252369620cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Fri, 30 Oct 2020 00:00:00 +0000 Subject: [PATCH 2/2] Add a test for compiletest rustc-env & unset-rustc-env directives --- src/test/ui/meta/auxiliary/env.rs | 9 +++++++++ src/test/ui/meta/rustc-env.rs | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/test/ui/meta/auxiliary/env.rs create mode 100644 src/test/ui/meta/rustc-env.rs diff --git a/src/test/ui/meta/auxiliary/env.rs b/src/test/ui/meta/auxiliary/env.rs new file mode 100644 index 0000000000000..b3644d8d5943f --- /dev/null +++ b/src/test/ui/meta/auxiliary/env.rs @@ -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"); +} diff --git a/src/test/ui/meta/rustc-env.rs b/src/test/ui/meta/rustc-env.rs new file mode 100644 index 0000000000000..7d4e005be10cf --- /dev/null +++ b/src/test/ui/meta/rustc-env.rs @@ -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(); +}