mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
compiletest: Introduce // {check,build,run}-pass
pass modes
This commit is contained in:
parent
374c63e0fc
commit
6203f68735
@ -1,4 +1,4 @@
|
||||
// revisions:rpass1 rpass2
|
||||
// revisions:cfail1 cfail2
|
||||
// compile-flags: --crate-type cdylib
|
||||
// skip-codegen
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
// Test that with the `skip-codegen` option the test isn't executed.
|
||||
|
||||
// skip-codegen
|
||||
|
||||
fn main() {
|
||||
unreachable!();
|
||||
}
|
@ -290,6 +290,13 @@ impl EarlyProps {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum PassMode {
|
||||
Check,
|
||||
Build,
|
||||
Run,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TestProps {
|
||||
// Lines that should be expected, in order, on standard out
|
||||
@ -349,14 +356,10 @@ pub struct TestProps {
|
||||
// testing harness and used when generating compilation
|
||||
// arguments. (In particular, it propagates to the aux-builds.)
|
||||
pub incremental_dir: Option<PathBuf>,
|
||||
// Specifies that a test must actually compile without errors.
|
||||
pub compile_pass: bool,
|
||||
// How far should the test proceed while still passing.
|
||||
pub pass_mode: Option<PassMode>,
|
||||
// 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.
|
||||
pub run_pass: bool,
|
||||
// Skip any codegen step and running the executable. Only for run-pass.
|
||||
pub skip_codegen: bool,
|
||||
// Do not pass `-Z ui-testing` to UI tests
|
||||
pub disable_ui_testing_normalization: bool,
|
||||
// customized normalization rules
|
||||
@ -396,10 +399,8 @@ impl TestProps {
|
||||
pretty_compare_only: false,
|
||||
forbid_output: vec![],
|
||||
incremental_dir: None,
|
||||
compile_pass: false,
|
||||
pass_mode: None,
|
||||
check_test_line_numbers_match: false,
|
||||
run_pass: false,
|
||||
skip_codegen: false,
|
||||
disable_ui_testing_normalization: false,
|
||||
normalize_stdout: vec![],
|
||||
normalize_stderr: vec![],
|
||||
@ -525,17 +526,14 @@ impl TestProps {
|
||||
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);
|
||||
}
|
||||
|
||||
if !self.compile_pass {
|
||||
// run-pass implies compile_pass
|
||||
self.compile_pass = config.parse_compile_pass(ln) || self.run_pass;
|
||||
}
|
||||
|
||||
if !self.skip_codegen {
|
||||
self.skip_codegen = config.parse_skip_codegen(ln);
|
||||
if config.parse_name_directive(ln, "check-pass") ||
|
||||
config.parse_name_directive(ln, "skip-codegen") {
|
||||
self.pass_mode = Some(PassMode::Check);
|
||||
} else if config.parse_name_directive(ln, "build-pass") ||
|
||||
config.parse_name_directive(ln, "compile-pass") {
|
||||
self.pass_mode = Some(PassMode::Build);
|
||||
} else if config.parse_name_directive(ln, "run-pass") {
|
||||
self.pass_mode = Some(PassMode::Run);
|
||||
}
|
||||
|
||||
if !self.disable_ui_testing_normalization {
|
||||
@ -710,10 +708,6 @@ impl Config {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_compile_pass(&self, line: &str) -> bool {
|
||||
self.parse_name_directive(line, "compile-pass")
|
||||
}
|
||||
|
||||
fn parse_disable_ui_testing_normalization(&self, line: &str) -> bool {
|
||||
self.parse_name_directive(line, "disable-ui-testing-normalization")
|
||||
}
|
||||
@ -722,14 +716,6 @@ impl Config {
|
||||
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_skip_codegen(&self, line: &str) -> bool {
|
||||
self.parse_name_directive(line, "skip-codegen")
|
||||
}
|
||||
|
||||
fn parse_assembly_output(&self, line: &str) -> Option<String> {
|
||||
self.parse_name_value_directive(line, "assembly-output")
|
||||
.map(|r| r.trim().to_string())
|
||||
|
@ -10,7 +10,7 @@ use crate::common::{Config, TestPaths};
|
||||
use crate::common::{Incremental, MirOpt, RunMake, Ui, JsDocTest, Assembly};
|
||||
use diff;
|
||||
use crate::errors::{self, Error, ErrorKind};
|
||||
use crate::header::TestProps;
|
||||
use crate::header::{TestProps, PassMode};
|
||||
use crate::json;
|
||||
use regex::{Captures, Regex};
|
||||
use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
|
||||
@ -310,20 +310,19 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
|
||||
fn should_run_successfully(&self) -> bool {
|
||||
let run_pass = match self.config.mode {
|
||||
match self.config.mode {
|
||||
RunPass => true,
|
||||
Ui => self.props.run_pass,
|
||||
_ => unimplemented!(),
|
||||
};
|
||||
return run_pass && !self.props.skip_codegen;
|
||||
Ui => self.props.pass_mode == Some(PassMode::Run),
|
||||
mode => panic!("unimplemented for mode {:?}", mode),
|
||||
}
|
||||
}
|
||||
|
||||
fn should_compile_successfully(&self) -> bool {
|
||||
match self.config.mode {
|
||||
CompileFail => self.props.compile_pass,
|
||||
CompileFail => false,
|
||||
RunPass => true,
|
||||
JsDocTest => true,
|
||||
Ui => self.props.compile_pass,
|
||||
Ui => self.props.pass_mode.is_some(),
|
||||
Incremental => {
|
||||
let revision = self.revision
|
||||
.expect("incremental tests require a list of revisions");
|
||||
@ -331,7 +330,7 @@ impl<'test> TestCx<'test> {
|
||||
true
|
||||
} else if revision.starts_with("cfail") {
|
||||
// FIXME: would be nice if incremental revs could start with "cpass"
|
||||
self.props.compile_pass
|
||||
self.props.pass_mode.is_some()
|
||||
} else {
|
||||
panic!("revision name must begin with rpass, rfail, or cfail");
|
||||
}
|
||||
@ -433,11 +432,9 @@ impl<'test> TestCx<'test> {
|
||||
"run-pass tests with expected warnings should be moved to ui/"
|
||||
);
|
||||
|
||||
if !self.props.skip_codegen {
|
||||
let proc_res = self.exec_compiled_test();
|
||||
if !proc_res.status.success() {
|
||||
self.fatal_proc_rec("test run failed!", &proc_res);
|
||||
}
|
||||
let proc_res = self.exec_compiled_test();
|
||||
if !proc_res.status.success() {
|
||||
self.fatal_proc_rec("test run failed!", &proc_res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1344,7 +1341,7 @@ impl<'test> TestCx<'test> {
|
||||
fn check_error_patterns(&self, output_to_check: &str, proc_res: &ProcRes) {
|
||||
debug!("check_error_patterns");
|
||||
if self.props.error_patterns.is_empty() {
|
||||
if self.props.compile_pass {
|
||||
if self.props.pass_mode.is_some() {
|
||||
return;
|
||||
} else {
|
||||
self.fatal(&format!(
|
||||
@ -1971,7 +1968,7 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
}
|
||||
|
||||
if self.props.skip_codegen {
|
||||
if self.props.pass_mode == Some(PassMode::Check) {
|
||||
assert!(
|
||||
!self
|
||||
.props
|
||||
|
Loading…
Reference in New Issue
Block a user