ui tests: Remap test base directory by default.

This commit is contained in:
Tim Neumann 2023-01-06 11:49:07 +00:00
parent 10fe7bfc73
commit cd1d0bc20c
13 changed files with 52 additions and 53 deletions

View File

@ -278,6 +278,9 @@ impl TestProps {
/// `//[foo]`), then the property is ignored unless `cfg` is
/// `Some("foo")`.
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
// Mode-dependent defaults.
self.remap_src_base = config.mode == Mode::Ui && !config.suite.contains("rustdoc");
let mut has_edition = false;
if !testfile.is_dir() {
let file = File::open(testfile).unwrap();

View File

@ -2,6 +2,7 @@
// Testing that a librustc_ast can parse modules with canonicalized base path
// ignore-cross-compile
// ignore-remote
// no-remap-src-base: Reading `file!()` (expectedly) fails when enabled.
#![feature(rustc_private)]

View File

@ -1,3 +1,4 @@
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
pub struct SomeStruct {} // This line should be show as part of the error.

View File

@ -1,10 +1,10 @@
error[E0423]: expected value, found struct `remapped_dep::SomeStruct`
--> $DIR/remap-path-prefix-reverse.rs:22:13
--> $DIR/remap-path-prefix-reverse.rs:16:13
|
LL | let _ = remapped_dep::SomeStruct;
LL | let _ = remapped_dep::SomeStruct; // ~ERROR E0423
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}`
|
::: remapped-aux/remapped_dep.rs:3:1
::: remapped-aux/remapped_dep.rs:4:1
|
LL | pub struct SomeStruct {} // This line should be show as part of the error.
| --------------------- `remapped_dep::SomeStruct` defined here

View File

@ -1,10 +1,10 @@
error[E0423]: expected value, found struct `remapped_dep::SomeStruct`
--> remapped/errors/remap-path-prefix-reverse.rs:22:13
--> $DIR/remap-path-prefix-reverse.rs:16:13
|
LL | let _ = remapped_dep::SomeStruct;
LL | let _ = remapped_dep::SomeStruct; // ~ERROR E0423
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}`
|
::: remapped-aux/remapped_dep.rs:3:1
::: remapped-aux/remapped_dep.rs:4:1
|
LL | pub struct SomeStruct {} // This line should be show as part of the error.
| --------------------- `remapped_dep::SomeStruct` defined here

View File

@ -1,15 +1,9 @@
// aux-build:remapped_dep.rs
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
// The remapped paths are not normalized by compiletest.
// normalize-stderr-test: "\\(errors)" -> "/$1"
// revisions: local-self remapped-self
// [remapped-self]compile-flags: --remap-path-prefix={{src-base}}=remapped
// The paths from `remapped-self` aren't recognized by compiletest, so we
// cannot use line-specific patterns for the actual error.
// error-pattern: E0423
// [local-self] no-remap-src-base: The hack should work regardless of remapping.
// [remapped-self] remap-src-base
// Verify that the expected source code is shown.
// error-pattern: pub struct SomeStruct {} // This line should be show
@ -19,5 +13,5 @@ extern crate remapped_dep;
fn main() {
// The actual error is irrelevant. The important part it that is should show
// a snippet of the dependency's source.
let _ = remapped_dep::SomeStruct;
let _ = remapped_dep::SomeStruct; // ~ERROR E0423
}

View File

@ -1,4 +1,5 @@
// compile-flags: --remap-path-prefix={{src-base}}=remapped
// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
// The remapped paths are not normalized by compiletest.
// normalize-stderr-test: "\\(errors)" -> "/$1"

View File

@ -1,5 +1,5 @@
error[E0425]: cannot find value `ferris` in this scope
--> remapped/errors/remap-path-prefix.rs:15:5
--> remapped/errors/remap-path-prefix.rs:16:5
|
LL | ferris
| ^^^^^^ not found in this scope

View File

@ -1,4 +1,6 @@
// aux-build:expand-expr.rs
// no-remap-src-base: check_expand_expr_file!() fails when enabled.
#![feature(concat_bytes)]
extern crate expand_expr;
@ -8,7 +10,7 @@ use expand_expr::{
// Check builtin macros can be expanded.
expand_expr_is!(11u32, line!());
expand_expr_is!(13u32, line!());
expand_expr_is!(24u32, column!());
expand_expr_is!("Hello, World!", concat!("Hello, ", "World", "!"));

View File

@ -1,29 +1,29 @@
error: expected one of `.`, `?`, or an operator, found `;`
--> $DIR/expand-expr.rs:106:27
--> $DIR/expand-expr.rs:108:27
|
LL | expand_expr_fail!("string"; hello);
| ^ expected one of `.`, `?`, or an operator
error: expected expression, found `$`
--> $DIR/expand-expr.rs:109:19
--> $DIR/expand-expr.rs:111:19
|
LL | expand_expr_fail!($);
| ^ expected expression
error: expected expression, found `$`
--> $DIR/expand-expr.rs:38:23
--> $DIR/expand-expr.rs:40:23
|
LL | ($($t:tt)*) => { $($t)* };
| ^^^^ expected expression
error: expected expression, found `$`
--> $DIR/expand-expr.rs:111:28
--> $DIR/expand-expr.rs:113:28
|
LL | expand_expr_fail!(echo_pm!($));
| ^ expected expression
error: macro expansion ignores token `hello` and any following
--> $DIR/expand-expr.rs:115:47
--> $DIR/expand-expr.rs:117:47
|
LL | expand_expr_is!("string", echo_tts!("string"; hello));
| --------------------^^^^^- caused by the macro expansion here
@ -35,7 +35,7 @@ LL | expand_expr_is!("string", echo_tts!("string"; hello););
| +
error: macro expansion ignores token `;` and any following
--> $DIR/expand-expr.rs:116:44
--> $DIR/expand-expr.rs:118:44
|
LL | expand_expr_is!("string", echo_pm!("string"; hello));
| -----------------^------- caused by the macro expansion here
@ -47,7 +47,7 @@ LL | expand_expr_is!("string", echo_pm!("string"; hello););
| +
error: recursion limit reached while expanding `recursive_expand!`
--> $DIR/expand-expr.rs:124:16
--> $DIR/expand-expr.rs:126:16
|
LL | const _: u32 = recursive_expand!();
| ^^^^^^^^^^^^^^^^^^^

View File

@ -1,5 +1,5 @@
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -10,7 +10,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: `#[deny(proc_macro_back_compat)]` on by default
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -20,7 +20,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -30,7 +30,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -40,7 +40,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -50,7 +50,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -60,7 +60,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -70,7 +70,7 @@ LL | enum ProceduralMasqueradeDummyType {
= note: older versions of the `rental` crate will stop compiling in future versions of Rust; please update to `rental` v0.5.6, or switch to one of the `rental` alternatives
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -83,7 +83,7 @@ error: aborting due to 8 previous errors
Future incompatibility report: Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -95,7 +95,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -107,7 +107,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -119,7 +119,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -131,7 +131,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -143,7 +143,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -155,7 +155,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -167,7 +167,7 @@ LL | enum ProceduralMasqueradeDummyType {
Future breakage diagnostic:
error: using an old version of `rental`
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
|
LL | enum ProceduralMasqueradeDummyType {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -3,21 +3,21 @@ PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "enum",
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:1: 4:5 (#0),
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:1: 4:5 (#0),
},
Ident {
ident: "ProceduralMasqueradeDummyType",
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6: 4:35 (#0),
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6: 4:35 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "Input",
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:13:5: 13:10 (#0),
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:13:5: 13:10 (#0),
},
],
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
},
]
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input, }
@ -25,20 +25,20 @@ PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input
PRINT-DERIVE INPUT (DEBUG): TokenStream [
Ident {
ident: "enum",
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:1: 4:5 (#0),
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:1: 4:5 (#0),
},
Ident {
ident: "ProceduralMasqueradeDummyType",
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6: 4:35 (#0),
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6: 4:35 (#0),
},
Group {
delimiter: Brace,
stream: TokenStream [
Ident {
ident: "Input",
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:13:5: 13:10 (#0),
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:13:5: 13:10 (#0),
},
],
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:36: 14:2 (#0),
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:36: 14:2 (#0),
},
]

View File

@ -1,11 +1,8 @@
// aux-build:test-macros.rs
// compile-flags: -Z span-debug
// revisions: local remapped
// [remapped]compile-flags: --remap-path-prefix={{src-base}}=remapped
// The remapped paths are not normalized by compiletest.
// normalize-stdout-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
// normalize-stderr-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
// [local] no-remap-src-base: The hack should work regardless of remapping.
// [remapped] remap-src-base
#![no_std] // Don't load unnecessary hygiene information from std
extern crate std;