Implement opt-out from UI testing normalization
This commit is contained in:
parent
fa2d9fc4b9
commit
e650eef8b0
4 changed files with 140 additions and 3 deletions
104
src/test/ui/ui-testing-optout.rs
Normal file
104
src/test/ui/ui-testing-optout.rs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
// disable-ui-testing-normalization
|
||||
|
||||
// Line number < 10
|
||||
type A = B; //~ ERROR
|
||||
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Line number >=10, <100
|
||||
type C = D; //~ ERROR
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Line num >=100
|
||||
type E = F; //~ ERROR
|
||||
|
||||
fn main() {}
|
||||
20
src/test/ui/ui-testing-optout.stderr
Normal file
20
src/test/ui/ui-testing-optout.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error[E0412]: cannot find type `B` in this scope
|
||||
--> $DIR/ui-testing-optout.rs:4:10
|
||||
|
|
||||
4 | type A = B; //~ ERROR
|
||||
| ^ did you mean `A`?
|
||||
|
||||
error[E0412]: cannot find type `D` in this scope
|
||||
--> $DIR/ui-testing-optout.rs:17:10
|
||||
|
|
||||
17 | type C = D; //~ ERROR
|
||||
| ^ did you mean `A`?
|
||||
|
||||
error[E0412]: cannot find type `F` in this scope
|
||||
--> $DIR/ui-testing-optout.rs:102:10
|
||||
|
|
||||
102 | type E = F; //~ ERROR
|
||||
| ^ did you mean `A`?
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
@ -226,9 +226,10 @@ pub struct TestProps {
|
|||
pub must_compile_successfully: bool,
|
||||
// rustdoc will test the output of the `--test` option
|
||||
pub check_test_line_numbers_match: bool,
|
||||
// The test must be compiled and run successfully. Only used in UI tests for
|
||||
// now.
|
||||
// The test must be compiled and run successfully. Only used in UI tests for now.
|
||||
pub run_pass: bool,
|
||||
// Do not pass `-Z ui-testing` to UI tests
|
||||
pub disable_ui_testing_normalization: bool,
|
||||
// customized normalization rules
|
||||
pub normalize_stdout: Vec<(String, String)>,
|
||||
pub normalize_stderr: Vec<(String, String)>,
|
||||
|
|
@ -259,6 +260,7 @@ impl TestProps {
|
|||
must_compile_successfully: false,
|
||||
check_test_line_numbers_match: false,
|
||||
run_pass: false,
|
||||
disable_ui_testing_normalization: false,
|
||||
normalize_stdout: vec![],
|
||||
normalize_stderr: vec![],
|
||||
failure_status: 101,
|
||||
|
|
@ -379,6 +381,11 @@ impl TestProps {
|
|||
config.parse_must_compile_successfully(ln) || self.run_pass;
|
||||
}
|
||||
|
||||
if !self.disable_ui_testing_normalization {
|
||||
self.disable_ui_testing_normalization =
|
||||
config.parse_disable_ui_testing_normalization(ln);
|
||||
}
|
||||
|
||||
if let Some(rule) = config.parse_custom_normalization(ln, "normalize-stdout") {
|
||||
self.normalize_stdout.push(rule);
|
||||
}
|
||||
|
|
@ -505,6 +512,10 @@ impl Config {
|
|||
self.parse_name_directive(line, "must-compile-successfully")
|
||||
}
|
||||
|
||||
fn parse_disable_ui_testing_normalization(&self, line: &str) -> bool {
|
||||
self.parse_name_directive(line, "disable-ui-testing-normalization")
|
||||
}
|
||||
|
||||
fn parse_check_test_line_numbers_match(&self, line: &str) -> bool {
|
||||
self.parse_name_directive(line, "check-test-line-numbers-match")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1632,7 +1632,9 @@ impl<'test> TestCx<'test> {
|
|||
// a first time to get the compiler's output then compile with
|
||||
// "--error-format json" to check if all expected errors are actually there
|
||||
// and that no new one appeared.
|
||||
rustc.arg("-Zui-testing");
|
||||
if !self.props.disable_ui_testing_normalization {
|
||||
rustc.arg("-Zui-testing");
|
||||
}
|
||||
}
|
||||
MirOpt => {
|
||||
rustc.args(&[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue