Skip to content

Commit

Permalink
ui tests: Remap test base directory by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
TimNN committed Jan 16, 2023
1 parent 10fe7bf commit cd1d0bc
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 53 deletions.
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/ui-fulldeps/mod_dir_path_canonicalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/errors/auxiliary/remapped_dep.rs
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions tests/ui/errors/remap-path-prefix-reverse.local-self.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 3 additions & 9 deletions tests/ui/errors/remap-path-prefix-reverse.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
1 change: 1 addition & 0 deletions tests/ui/errors/remap-path-prefix.rs
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/errors/remap-path-prefix.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/proc-macro/expand-expr.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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", "!"));
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/proc-macro/expand-expr.stderr
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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!();
| ^^^^^^^^^^^^^^^^^^^
Expand Down
32 changes: 16 additions & 16 deletions tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr
Original file line number Diff line number Diff line change
@@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -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 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/proc-macro/pretty-print-hack-show.remapped.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@ 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, }
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),
},
]
7 changes: 2 additions & 5 deletions tests/ui/proc-macro/pretty-print-hack-show.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit cd1d0bc

Please sign in to comment.