mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-09 21:42:44 +00:00
Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516.
The 'run-pass' header cause a 'ui' test to execute the result. It is used to test the lint output, at the same time ensure those lints won't cause the source code to become compile-fail. 12 run-pass/run-pass-fulldeps tests gained the header and are moved to ui/ui-fulldeps. After this move, no run-pass/run-pass-fulldeps tests should rely on the compiler's JSON message. This allows us to stop passing `--error-format json` in run-pass tests, thus fixing #36516.
This commit is contained in:
parent
d7798c3d17
commit
38ef85696d
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
#![feature(rustc_private)]
|
#![feature(rustc_private)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
6
src/test/ui-fulldeps/deprecated-derive.stderr
Normal file
6
src/test/ui-fulldeps/deprecated-derive.stderr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
warning: derive(Encodable) is deprecated in favor of derive(RustcEncodable)
|
||||||
|
--> $DIR/deprecated-derive.rs:18:10
|
||||||
|
|
|
||||||
|
18 | #[derive(Encodable)]
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
// aux-build:lint_group_plugin_test.rs
|
// aux-build:lint_group_plugin_test.rs
|
||||||
// ignore-stage1
|
// ignore-stage1
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
16
src/test/ui-fulldeps/lint-group-plugin.stderr
Normal file
16
src/test/ui-fulldeps/lint-group-plugin.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
warning: item is named 'lintme'
|
||||||
|
--> $DIR/lint-group-plugin.rs:18:1
|
||||||
|
|
|
||||||
|
18 | fn lintme() { } //~ WARNING item is named 'lintme'
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(test_lint)] on by default
|
||||||
|
|
||||||
|
warning: item is named 'pleaselintme'
|
||||||
|
--> $DIR/lint-group-plugin.rs:19:1
|
||||||
|
|
|
||||||
|
19 | fn pleaselintme() { } //~ WARNING item is named 'pleaselintme'
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(please_lint)] on by default
|
||||||
|
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
// aux-build:lint_plugin_test.rs
|
// aux-build:lint_plugin_test.rs
|
||||||
// ignore-stage1
|
// ignore-stage1
|
||||||
// compile-flags: -A test-lint
|
// compile-flags: -A test-lint
|
8
src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr
Normal file
8
src/test/ui-fulldeps/lint-plugin-cmdline-allow.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
warning: function is never used: `lintme`
|
||||||
|
--> $DIR/lint-plugin-cmdline-allow.rs:19:1
|
||||||
|
|
|
||||||
|
19 | fn lintme() { }
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(dead_code)] on by default
|
||||||
|
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
// aux-build:lint_plugin_test.rs
|
// aux-build:lint_plugin_test.rs
|
||||||
// ignore-stage1
|
// ignore-stage1
|
||||||
// compile-flags: -Z extra-plugins=lint_plugin_test
|
// compile-flags: -Z extra-plugins=lint_plugin_test
|
8
src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr
Normal file
8
src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
warning: item is named 'lintme'
|
||||||
|
--> $DIR/lint-plugin-cmdline-load.rs:18:1
|
||||||
|
|
|
||||||
|
18 | fn lintme() { } //~ WARNING item is named 'lintme'
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(test_lint)] on by default
|
||||||
|
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
// aux-build:lint_plugin_test.rs
|
// aux-build:lint_plugin_test.rs
|
||||||
// ignore-stage1
|
// ignore-stage1
|
||||||
#![feature(plugin)]
|
#![feature(plugin)]
|
8
src/test/ui-fulldeps/lint-plugin.stderr
Normal file
8
src/test/ui-fulldeps/lint-plugin.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
warning: item is named 'lintme'
|
||||||
|
--> $DIR/lint-plugin.rs:18:1
|
||||||
|
|
|
||||||
|
18 | fn lintme() { } //~ WARNING item is named 'lintme'
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(test_lint)] on by default
|
||||||
|
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
mod foo {
|
mod foo {
|
||||||
#![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
#![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
||||||
//~^ HELP consider an outer attribute
|
//~^ HELP consider an outer attribute
|
8
src/test/ui/deprecated-macro_escape-inner.stderr
Normal file
8
src/test/ui/deprecated-macro_escape-inner.stderr
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
warning: macro_escape is a deprecated synonym for macro_use
|
||||||
|
--> $DIR/deprecated-macro_escape-inner.rs:14:5
|
||||||
|
|
|
||||||
|
14 | #![macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: consider an outer attribute, #[macro_use] mod ...
|
||||||
|
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
#[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
#[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
||||||
mod foo {
|
mod foo {
|
||||||
}
|
}
|
6
src/test/ui/deprecated-macro_escape.stderr
Normal file
6
src/test/ui/deprecated-macro_escape.stderr
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
warning: macro_escape is a deprecated synonym for macro_use
|
||||||
|
--> $DIR/deprecated-macro_escape.rs:13:1
|
||||||
|
|
|
||||||
|
13 | #[macro_escape] //~ WARNING macro_escape is a deprecated synonym for macro_use
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
#[derive] //~ WARNING empty trait list in `derive`
|
#[derive] //~ WARNING empty trait list in `derive`
|
12
src/test/ui/deriving-meta-empty-trait-list.stderr
Normal file
12
src/test/ui/deriving-meta-empty-trait-list.stderr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
warning: empty trait list in `derive`
|
||||||
|
--> $DIR/deriving-meta-empty-trait-list.rs:15:1
|
||||||
|
|
|
||||||
|
15 | #[derive] //~ WARNING empty trait list in `derive`
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
warning: empty trait list in `derive`
|
||||||
|
--> $DIR/deriving-meta-empty-trait-list.rs:18:1
|
||||||
|
|
|
||||||
|
18 | #[derive()] //~ WARNING empty trait list in `derive`
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
@ -7,7 +7,13 @@
|
|||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
//
|
|
||||||
|
// run-pass
|
||||||
|
// ignore-x86
|
||||||
|
// ignore-arm
|
||||||
|
// ignore-emscripten
|
||||||
|
// ^ ignore 32-bit targets, as the error message is target-dependent. see PR #41968.
|
||||||
|
|
||||||
#![warn(variant_size_differences)]
|
#![warn(variant_size_differences)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
12
src/test/ui/enum-size-variance.stderr
Normal file
12
src/test/ui/enum-size-variance.stderr
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
warning: enum variant is more than three times larger (32 bytes) than the next largest
|
||||||
|
--> $DIR/enum-size-variance.rs:32:5
|
||||||
|
|
|
||||||
|
32 | L(isize, isize, isize, isize), //~ WARNING three times larger
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
note: lint level defined here
|
||||||
|
--> $DIR/enum-size-variance.rs:17:9
|
||||||
|
|
|
||||||
|
17 | #![warn(variant_size_differences)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
16
src/test/ui/issue-19100.stderr
Normal file
16
src/test/ui/issue-19100.stderr
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
warning[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo`
|
||||||
|
--> $DIR/issue-19100.rs:27:1
|
||||||
|
|
|
||||||
|
27 | Bar if true
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `Foo::Bar`
|
||||||
|
|
||||||
|
warning[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo`
|
||||||
|
--> $DIR/issue-19100.rs:32:1
|
||||||
|
|
|
||||||
|
32 | Baz if false
|
||||||
|
| ^^^
|
||||||
|
|
|
||||||
|
= help: if you meant to match on a variant, consider making the path in the pattern qualified: `Foo::Baz`
|
||||||
|
|
@ -8,6 +8,8 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
|
|
||||||
// Parser test for #37765
|
// Parser test for #37765
|
||||||
|
|
||||||
fn with_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `with_parens`
|
fn with_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `with_parens`
|
28
src/test/ui/path-lookahead.stderr
Normal file
28
src/test/ui/path-lookahead.stderr
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
warning: unnecessary parentheses around `return` value
|
||||||
|
--> $DIR/path-lookahead.rs:16:10
|
||||||
|
|
|
||||||
|
16 | return (<T as ToString>::to_string(&arg)); //~WARN unnecessary parentheses around `return` value
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: #[warn(unused_parens)] on by default
|
||||||
|
|
||||||
|
warning: function is never used: `with_parens`
|
||||||
|
--> $DIR/path-lookahead.rs:15:1
|
||||||
|
|
|
||||||
|
15 | / fn with_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `with_parens`
|
||||||
|
16 | | return (<T as ToString>::to_string(&arg)); //~WARN unnecessary parentheses around `return` value
|
||||||
|
17 | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= note: #[warn(dead_code)] on by default
|
||||||
|
|
||||||
|
warning: function is never used: `no_parens`
|
||||||
|
--> $DIR/path-lookahead.rs:19:1
|
||||||
|
|
|
||||||
|
19 | / fn no_parens<T: ToString>(arg: T) -> String { //~WARN function is never used: `no_parens`
|
||||||
|
20 | | return <T as ToString>::to_string(&arg);
|
||||||
|
21 | | }
|
||||||
|
| |_^
|
||||||
|
|
|
||||||
|
= note: #[warn(dead_code)] on by default
|
||||||
|
|
@ -8,6 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// run-pass
|
||||||
// compile-flags: --test
|
// compile-flags: --test
|
||||||
|
|
||||||
#[test]
|
#[test]
|
40
src/test/ui/test-should-panic-attr.stderr
Normal file
40
src/test/ui/test-should-panic-attr.stderr
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
warning: attribute must be of the form: `#[should_panic]` or `#[should_panic(expected = "error message")]`
|
||||||
|
--> $DIR/test-should-panic-attr.rs:15:1
|
||||||
|
|
|
||||||
|
15 | #[should_panic = "foo"]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
|
||||||
|
|
||||||
|
warning: argument must be of the form: `expected = "error message"`
|
||||||
|
--> $DIR/test-should-panic-attr.rs:22:1
|
||||||
|
|
|
||||||
|
22 | #[should_panic(expected)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
|
||||||
|
|
||||||
|
warning: argument must be of the form: `expected = "error message"`
|
||||||
|
--> $DIR/test-should-panic-attr.rs:29:1
|
||||||
|
|
|
||||||
|
29 | #[should_panic(expect)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
|
||||||
|
|
||||||
|
warning: argument must be of the form: `expected = "error message"`
|
||||||
|
--> $DIR/test-should-panic-attr.rs:36:1
|
||||||
|
|
|
||||||
|
36 | #[should_panic(expected(foo, bar))]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
|
||||||
|
|
||||||
|
warning: argument must be of the form: `expected = "error message"`
|
||||||
|
--> $DIR/test-should-panic-attr.rs:43:1
|
||||||
|
|
|
||||||
|
43 | #[should_panic(expected = "foo", bar)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: Errors in this attribute were erroneously allowed and will become a hard error in a future release.
|
||||||
|
|
@ -233,6 +233,9 @@ pub struct TestProps {
|
|||||||
pub must_compile_successfully: bool,
|
pub must_compile_successfully: bool,
|
||||||
// rustdoc will test the output of the `--test` option
|
// rustdoc will test the output of the `--test` option
|
||||||
pub check_test_line_numbers_match: bool,
|
pub check_test_line_numbers_match: bool,
|
||||||
|
// The test must be compiled and run successfully. Only used in UI tests for
|
||||||
|
// now.
|
||||||
|
pub run_pass: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestProps {
|
impl TestProps {
|
||||||
@ -258,6 +261,7 @@ impl TestProps {
|
|||||||
incremental_dir: None,
|
incremental_dir: None,
|
||||||
must_compile_successfully: false,
|
must_compile_successfully: false,
|
||||||
check_test_line_numbers_match: false,
|
check_test_line_numbers_match: false,
|
||||||
|
run_pass: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +372,10 @@ impl TestProps {
|
|||||||
if !self.check_test_line_numbers_match {
|
if !self.check_test_line_numbers_match {
|
||||||
self.check_test_line_numbers_match = config.parse_check_test_line_numbers_match(ln);
|
self.check_test_line_numbers_match = config.parse_check_test_line_numbers_match(ln);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !self.run_pass {
|
||||||
|
self.run_pass = config.parse_run_pass(ln);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
|
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
|
||||||
@ -485,6 +493,10 @@ impl Config {
|
|||||||
self.parse_name_directive(line, "check-test-line-numbers-match")
|
self.parse_name_directive(line, "check-test-line-numbers-match")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_run_pass(&self, line: &str) -> bool {
|
||||||
|
self.parse_name_directive(line, "run-pass")
|
||||||
|
}
|
||||||
|
|
||||||
fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
|
fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
|
||||||
self.parse_name_value_directive(line, name).map(|nv| {
|
self.parse_name_value_directive(line, name).map(|nv| {
|
||||||
// nv is either FOO or FOO=BAR
|
// nv is either FOO or FOO=BAR
|
||||||
|
@ -214,10 +214,10 @@ impl<'test> TestCx<'test> {
|
|||||||
self.fatal_proc_rec("compilation failed!", &proc_res);
|
self.fatal_proc_rec("compilation failed!", &proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME(#41968): Move this check to tidy?
|
||||||
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
|
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
|
||||||
if !expected_errors.is_empty() {
|
assert!(expected_errors.is_empty(),
|
||||||
self.check_expected_errors(expected_errors, &proc_res);
|
"run-pass tests with expected warnings should be moved to ui/");
|
||||||
}
|
|
||||||
|
|
||||||
let proc_res = self.exec_compiled_test();
|
let proc_res = self.exec_compiled_test();
|
||||||
|
|
||||||
@ -1394,7 +1394,6 @@ actual:\n\
|
|||||||
match self.config.mode {
|
match self.config.mode {
|
||||||
CompileFail |
|
CompileFail |
|
||||||
ParseFail |
|
ParseFail |
|
||||||
RunPass |
|
|
||||||
Incremental => {
|
Incremental => {
|
||||||
// If we are extracting and matching errors in the new
|
// If we are extracting and matching errors in the new
|
||||||
// fashion, then you want JSON mode. Old-skool error
|
// fashion, then you want JSON mode. Old-skool error
|
||||||
@ -1422,6 +1421,7 @@ actual:\n\
|
|||||||
|
|
||||||
args.push(dir_opt);
|
args.push(dir_opt);
|
||||||
}
|
}
|
||||||
|
RunPass |
|
||||||
RunFail |
|
RunFail |
|
||||||
RunPassValgrind |
|
RunPassValgrind |
|
||||||
Pretty |
|
Pretty |
|
||||||
@ -2254,6 +2254,14 @@ actual:\n\
|
|||||||
self.fatal_proc_rec(&format!("{} errors occurred comparing output.", errors),
|
self.fatal_proc_rec(&format!("{} errors occurred comparing output.", errors),
|
||||||
&proc_res);
|
&proc_res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.props.run_pass {
|
||||||
|
let proc_res = self.exec_compiled_test();
|
||||||
|
|
||||||
|
if !proc_res.status.success() {
|
||||||
|
self.fatal_proc_rec("test run failed!", &proc_res);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_mir_opt_test(&self) {
|
fn run_mir_opt_test(&self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user