Skip to content

Commit cd1d0bc

Browse files
committed
ui tests: Remap test base directory by default.
1 parent 10fe7bf commit cd1d0bc

13 files changed

+52
-53
lines changed

src/tools/compiletest/src/header.rs

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

tests/ui-fulldeps/mod_dir_path_canonicalized.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Testing that a librustc_ast can parse modules with canonicalized base path
33
// ignore-cross-compile
44
// ignore-remote
5+
// no-remap-src-base: Reading `file!()` (expectedly) fails when enabled.
56

67
#![feature(rustc_private)]
78

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
2+
// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
23

34
pub struct SomeStruct {} // This line should be show as part of the error.

tests/ui/errors/remap-path-prefix-reverse.local-self.stderr

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

tests/ui/errors/remap-path-prefix-reverse.remapped-self.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
error[E0423]: expected value, found struct `remapped_dep::SomeStruct`
2-
--> remapped/errors/remap-path-prefix-reverse.rs:22:13
2+
--> $DIR/remap-path-prefix-reverse.rs:16:13
33
|
4-
LL | let _ = remapped_dep::SomeStruct;
4+
LL | let _ = remapped_dep::SomeStruct; // ~ERROR E0423
55
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use struct literal syntax instead: `remapped_dep::SomeStruct {}`
66
|
7-
::: remapped-aux/remapped_dep.rs:3:1
7+
::: remapped-aux/remapped_dep.rs:4:1
88
|
99
LL | pub struct SomeStruct {} // This line should be show as part of the error.
1010
| --------------------- `remapped_dep::SomeStruct` defined here
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
// aux-build:remapped_dep.rs
22
// compile-flags: --remap-path-prefix={{src-base}}/errors/auxiliary=remapped-aux
33

4-
// The remapped paths are not normalized by compiletest.
5-
// normalize-stderr-test: "\\(errors)" -> "/$1"
6-
74
// revisions: local-self remapped-self
8-
// [remapped-self]compile-flags: --remap-path-prefix={{src-base}}=remapped
9-
10-
// The paths from `remapped-self` aren't recognized by compiletest, so we
11-
// cannot use line-specific patterns for the actual error.
12-
// error-pattern: E0423
5+
// [local-self] no-remap-src-base: The hack should work regardless of remapping.
6+
// [remapped-self] remap-src-base
137

148
// Verify that the expected source code is shown.
159
// error-pattern: pub struct SomeStruct {} // This line should be show
@@ -19,5 +13,5 @@ extern crate remapped_dep;
1913
fn main() {
2014
// The actual error is irrelevant. The important part it that is should show
2115
// a snippet of the dependency's source.
22-
let _ = remapped_dep::SomeStruct;
16+
let _ = remapped_dep::SomeStruct; // ~ERROR E0423
2317
}

tests/ui/errors/remap-path-prefix.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-flags: --remap-path-prefix={{src-base}}=remapped
2+
// no-remap-src-base: Manually remap, so the remapped path remains in .stderr file.
23

34
// The remapped paths are not normalized by compiletest.
45
// normalize-stderr-test: "\\(errors)" -> "/$1"

tests/ui/errors/remap-path-prefix.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find value `ferris` in this scope
2-
--> remapped/errors/remap-path-prefix.rs:15:5
2+
--> remapped/errors/remap-path-prefix.rs:16:5
33
|
44
LL | ferris
55
| ^^^^^^ not found in this scope

tests/ui/proc-macro/expand-expr.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// aux-build:expand-expr.rs
2+
// no-remap-src-base: check_expand_expr_file!() fails when enabled.
3+
24
#![feature(concat_bytes)]
35
extern crate expand_expr;
46

@@ -8,7 +10,7 @@ use expand_expr::{
810

911
// Check builtin macros can be expanded.
1012

11-
expand_expr_is!(11u32, line!());
13+
expand_expr_is!(13u32, line!());
1214
expand_expr_is!(24u32, column!());
1315

1416
expand_expr_is!("Hello, World!", concat!("Hello, ", "World", "!"));

tests/ui/proc-macro/expand-expr.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
error: expected one of `.`, `?`, or an operator, found `;`
2-
--> $DIR/expand-expr.rs:106:27
2+
--> $DIR/expand-expr.rs:108:27
33
|
44
LL | expand_expr_fail!("string"; hello);
55
| ^ expected one of `.`, `?`, or an operator
66

77
error: expected expression, found `$`
8-
--> $DIR/expand-expr.rs:109:19
8+
--> $DIR/expand-expr.rs:111:19
99
|
1010
LL | expand_expr_fail!($);
1111
| ^ expected expression
1212

1313
error: expected expression, found `$`
14-
--> $DIR/expand-expr.rs:38:23
14+
--> $DIR/expand-expr.rs:40:23
1515
|
1616
LL | ($($t:tt)*) => { $($t)* };
1717
| ^^^^ expected expression
1818

1919
error: expected expression, found `$`
20-
--> $DIR/expand-expr.rs:111:28
20+
--> $DIR/expand-expr.rs:113:28
2121
|
2222
LL | expand_expr_fail!(echo_pm!($));
2323
| ^ expected expression
2424

2525
error: macro expansion ignores token `hello` and any following
26-
--> $DIR/expand-expr.rs:115:47
26+
--> $DIR/expand-expr.rs:117:47
2727
|
2828
LL | expand_expr_is!("string", echo_tts!("string"; hello));
2929
| --------------------^^^^^- caused by the macro expansion here
@@ -35,7 +35,7 @@ LL | expand_expr_is!("string", echo_tts!("string"; hello););
3535
| +
3636

3737
error: macro expansion ignores token `;` and any following
38-
--> $DIR/expand-expr.rs:116:44
38+
--> $DIR/expand-expr.rs:118:44
3939
|
4040
LL | expand_expr_is!("string", echo_pm!("string"; hello));
4141
| -----------------^------- caused by the macro expansion here
@@ -47,7 +47,7 @@ LL | expand_expr_is!("string", echo_pm!("string"; hello););
4747
| +
4848

4949
error: recursion limit reached while expanding `recursive_expand!`
50-
--> $DIR/expand-expr.rs:124:16
50+
--> $DIR/expand-expr.rs:126:16
5151
|
5252
LL | const _: u32 = recursive_expand!();
5353
| ^^^^^^^^^^^^^^^^^^^

tests/ui/proc-macro/pretty-print-hack-show.remapped.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: using an old version of `rental`
2-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
2+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
33
|
44
LL | enum ProceduralMasqueradeDummyType {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | enum ProceduralMasqueradeDummyType {
1010
= note: `#[deny(proc_macro_back_compat)]` on by default
1111

1212
error: using an old version of `rental`
13-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
13+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
1414
|
1515
LL | enum ProceduralMasqueradeDummyType {
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -20,7 +20,7 @@ LL | enum ProceduralMasqueradeDummyType {
2020
= 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
2121

2222
error: using an old version of `rental`
23-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
23+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
2424
|
2525
LL | enum ProceduralMasqueradeDummyType {
2626
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -30,7 +30,7 @@ LL | enum ProceduralMasqueradeDummyType {
3030
= 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
3131

3232
error: using an old version of `rental`
33-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
33+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
3434
|
3535
LL | enum ProceduralMasqueradeDummyType {
3636
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -40,7 +40,7 @@ LL | enum ProceduralMasqueradeDummyType {
4040
= 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
4141

4242
error: using an old version of `rental`
43-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
43+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
4444
|
4545
LL | enum ProceduralMasqueradeDummyType {
4646
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -50,7 +50,7 @@ LL | enum ProceduralMasqueradeDummyType {
5050
= 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
5151

5252
error: using an old version of `rental`
53-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
53+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
5454
|
5555
LL | enum ProceduralMasqueradeDummyType {
5656
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -60,7 +60,7 @@ LL | enum ProceduralMasqueradeDummyType {
6060
= 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
6161

6262
error: using an old version of `rental`
63-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
63+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
6464
|
6565
LL | enum ProceduralMasqueradeDummyType {
6666
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -70,7 +70,7 @@ LL | enum ProceduralMasqueradeDummyType {
7070
= 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
7171

7272
error: using an old version of `rental`
73-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
73+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
7474
|
7575
LL | enum ProceduralMasqueradeDummyType {
7676
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -83,7 +83,7 @@ error: aborting due to 8 previous errors
8383

8484
Future incompatibility report: Future breakage diagnostic:
8585
error: using an old version of `rental`
86-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
86+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
8787
|
8888
LL | enum ProceduralMasqueradeDummyType {
8989
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -95,7 +95,7 @@ LL | enum ProceduralMasqueradeDummyType {
9595

9696
Future breakage diagnostic:
9797
error: using an old version of `rental`
98-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
98+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
9999
|
100100
LL | enum ProceduralMasqueradeDummyType {
101101
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -107,7 +107,7 @@ LL | enum ProceduralMasqueradeDummyType {
107107

108108
Future breakage diagnostic:
109109
error: using an old version of `rental`
110-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
110+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
111111
|
112112
LL | enum ProceduralMasqueradeDummyType {
113113
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -119,7 +119,7 @@ LL | enum ProceduralMasqueradeDummyType {
119119

120120
Future breakage diagnostic:
121121
error: using an old version of `rental`
122-
--> remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
122+
--> $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6
123123
|
124124
LL | enum ProceduralMasqueradeDummyType {
125125
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -131,7 +131,7 @@ LL | enum ProceduralMasqueradeDummyType {
131131

132132
Future breakage diagnostic:
133133
error: using an old version of `rental`
134-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
134+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
135135
|
136136
LL | enum ProceduralMasqueradeDummyType {
137137
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -143,7 +143,7 @@ LL | enum ProceduralMasqueradeDummyType {
143143

144144
Future breakage diagnostic:
145145
error: using an old version of `rental`
146-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
146+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
147147
|
148148
LL | enum ProceduralMasqueradeDummyType {
149149
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -155,7 +155,7 @@ LL | enum ProceduralMasqueradeDummyType {
155155

156156
Future breakage diagnostic:
157157
error: using an old version of `rental`
158-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
158+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
159159
|
160160
LL | enum ProceduralMasqueradeDummyType {
161161
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -167,7 +167,7 @@ LL | enum ProceduralMasqueradeDummyType {
167167

168168
Future breakage diagnostic:
169169
error: using an old version of `rental`
170-
--> remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
170+
--> $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6
171171
|
172172
LL | enum ProceduralMasqueradeDummyType {
173173
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/proc-macro/pretty-print-hack-show.remapped.stdout

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,42 @@ PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input
33
PRINT-DERIVE INPUT (DEBUG): TokenStream [
44
Ident {
55
ident: "enum",
6-
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:1: 4:5 (#0),
6+
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:1: 4:5 (#0),
77
},
88
Ident {
99
ident: "ProceduralMasqueradeDummyType",
10-
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6: 4:35 (#0),
10+
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:6: 4:35 (#0),
1111
},
1212
Group {
1313
delimiter: Brace,
1414
stream: TokenStream [
1515
Ident {
1616
ident: "Input",
17-
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:13:5: 13:10 (#0),
17+
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:13:5: 13:10 (#0),
1818
},
1919
],
20-
span: remapped/proc-macro/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
20+
span: $DIR/pretty-print-hack/allsorts-rental-0.5.6/src/lib.rs:4:36: 14:2 (#0),
2121
},
2222
]
2323
PRINT-DERIVE INPUT (DISPLAY): enum ProceduralMasqueradeDummyType { Input, }
2424
PRINT-DERIVE RE-COLLECTED (DISPLAY): enum ProceduralMasqueradeDummyType { Input }
2525
PRINT-DERIVE INPUT (DEBUG): TokenStream [
2626
Ident {
2727
ident: "enum",
28-
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:1: 4:5 (#0),
28+
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:1: 4:5 (#0),
2929
},
3030
Ident {
3131
ident: "ProceduralMasqueradeDummyType",
32-
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6: 4:35 (#0),
32+
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:6: 4:35 (#0),
3333
},
3434
Group {
3535
delimiter: Brace,
3636
stream: TokenStream [
3737
Ident {
3838
ident: "Input",
39-
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:13:5: 13:10 (#0),
39+
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:13:5: 13:10 (#0),
4040
},
4141
],
42-
span: remapped/proc-macro/pretty-print-hack/rental-0.5.5/src/lib.rs:4:36: 14:2 (#0),
42+
span: $DIR/pretty-print-hack/rental-0.5.5/src/lib.rs:4:36: 14:2 (#0),
4343
},
4444
]

tests/ui/proc-macro/pretty-print-hack-show.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
// aux-build:test-macros.rs
22
// compile-flags: -Z span-debug
33
// revisions: local remapped
4-
// [remapped]compile-flags: --remap-path-prefix={{src-base}}=remapped
5-
6-
// The remapped paths are not normalized by compiletest.
7-
// normalize-stdout-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
8-
// normalize-stderr-test: "\\(proc-macro|pretty-print-hack)" -> "/$1"
4+
// [local] no-remap-src-base: The hack should work regardless of remapping.
5+
// [remapped] remap-src-base
96

107
#![no_std] // Don't load unnecessary hygiene information from std
118
extern crate std;

0 commit comments

Comments
 (0)