Skip to content

Commit e650eef

Browse files
committed
Implement opt-out from UI testing normalization
1 parent fa2d9fc commit e650eef

File tree

4 files changed

+140
-3
lines changed

4 files changed

+140
-3
lines changed

src/test/ui/ui-testing-optout.rs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// disable-ui-testing-normalization
2+
3+
// Line number < 10
4+
type A = B; //~ ERROR
5+
6+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
7+
// file at the top-level directory of this distribution and at
8+
// http://rust-lang.org/COPYRIGHT.
9+
//
10+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
11+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
12+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
13+
// option. This file may not be copied, modified, or distributed
14+
// except according to those terms.
15+
16+
// Line number >=10, <100
17+
type C = D; //~ ERROR
18+
19+
20+
21+
22+
23+
24+
25+
26+
27+
28+
29+
30+
31+
32+
33+
34+
35+
36+
37+
38+
39+
40+
41+
42+
43+
44+
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
// Line num >=100
102+
type E = F; //~ ERROR
103+
104+
fn main() {}

src/test/ui/ui-testing-optout.stderr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0412]: cannot find type `B` in this scope
2+
--> $DIR/ui-testing-optout.rs:4:10
3+
|
4+
4 | type A = B; //~ ERROR
5+
| ^ did you mean `A`?
6+
7+
error[E0412]: cannot find type `D` in this scope
8+
--> $DIR/ui-testing-optout.rs:17:10
9+
|
10+
17 | type C = D; //~ ERROR
11+
| ^ did you mean `A`?
12+
13+
error[E0412]: cannot find type `F` in this scope
14+
--> $DIR/ui-testing-optout.rs:102:10
15+
|
16+
102 | type E = F; //~ ERROR
17+
| ^ did you mean `A`?
18+
19+
error: aborting due to 3 previous errors
20+

src/tools/compiletest/src/header.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,10 @@ pub struct TestProps {
226226
pub must_compile_successfully: bool,
227227
// rustdoc will test the output of the `--test` option
228228
pub check_test_line_numbers_match: bool,
229-
// The test must be compiled and run successfully. Only used in UI tests for
230-
// now.
229+
// The test must be compiled and run successfully. Only used in UI tests for now.
231230
pub run_pass: bool,
231+
// Do not pass `-Z ui-testing` to UI tests
232+
pub disable_ui_testing_normalization: bool,
232233
// customized normalization rules
233234
pub normalize_stdout: Vec<(String, String)>,
234235
pub normalize_stderr: Vec<(String, String)>,
@@ -259,6 +260,7 @@ impl TestProps {
259260
must_compile_successfully: false,
260261
check_test_line_numbers_match: false,
261262
run_pass: false,
263+
disable_ui_testing_normalization: false,
262264
normalize_stdout: vec![],
263265
normalize_stderr: vec![],
264266
failure_status: 101,
@@ -379,6 +381,11 @@ impl TestProps {
379381
config.parse_must_compile_successfully(ln) || self.run_pass;
380382
}
381383

384+
if !self.disable_ui_testing_normalization {
385+
self.disable_ui_testing_normalization =
386+
config.parse_disable_ui_testing_normalization(ln);
387+
}
388+
382389
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
383390
self.normalize_stdout.push(rule);
384391
}
@@ -505,6 +512,10 @@ impl Config {
505512
self.parse_name_directive(line, "must-compile-successfully")
506513
}
507514

515+
fn parse_disable_ui_testing_normalization(&self, line: &str) -> bool {
516+
self.parse_name_directive(line, "disable-ui-testing-normalization")
517+
}
518+
508519
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
509520
self.parse_name_directive(line, "check-test-line-numbers-match")
510521
}

src/tools/compiletest/src/runtest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,9 @@ impl<'test> TestCx<'test> {
16321632
// a first time to get the compiler's output then compile with
16331633
// "--error-format json" to check if all expected errors are actually there
16341634
// and that no new one appeared.
1635-
rustc.arg("-Zui-testing");
1635+
if !self.props.disable_ui_testing_normalization {
1636+
rustc.arg("-Zui-testing");
1637+
}
16361638
}
16371639
MirOpt => {
16381640
rustc.args(&[

0 commit comments

Comments
 (0)