1
Fork 0

Address review comments.

This commit is contained in:
Mazdak Farrokhzad 2019-06-24 18:32:52 +02:00
parent 5baac07d4b
commit 5eaedda9f5
6 changed files with 24 additions and 24 deletions

View file

@ -2,7 +2,6 @@
#![deny(overflowing_literals)] #![deny(overflowing_literals)]
#![deny(const_err)] #![deny(const_err)]
#![allow(unused_variables)]
fn main() { fn main() {
let x2: i8 = --128; //~ ERROR literal out of range for `i8` let x2: i8 = --128; //~ ERROR literal out of range for `i8`

View file

@ -1,6 +1,7 @@
// run-pass // run-pass
// force-host // force-host
// no-prefer-dynamic // no-prefer-dynamic
// ignore-pass
#![crate_type = "proc-macro"] #![crate_type = "proc-macro"]

View file

@ -1,4 +1,7 @@
// compile-pass // compile-pass
// compile-flags: -Zsave-analysis -Zemit-artifact-notifications // compile-flags: -Zsave-analysis -Zemit-artifact-notifications
// compile-flags: --crate-type rlib --error-format=json // compile-flags: --crate-type rlib --error-format=json
// ignore-pass
// ^-- needed because otherwise, the .stderr file changes with --pass check
pub fn foo() {} pub fn foo() {}

View file

@ -350,9 +350,9 @@ pub struct TestProps {
// arguments. (In particular, it propagates to the aux-builds.) // arguments. (In particular, it propagates to the aux-builds.)
pub incremental_dir: Option<PathBuf>, pub incremental_dir: Option<PathBuf>,
// How far should the test proceed while still passing. // How far should the test proceed while still passing.
pub pass_mode: Option<PassMode>, pass_mode: Option<PassMode>,
// Ignore `--pass` overrides from the command line for this test. // Ignore `--pass` overrides from the command line for this test.
pub ignore_pass: bool, ignore_pass: 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,
// Do not pass `-Z ui-testing` to UI tests // Do not pass `-Z ui-testing` to UI tests
@ -608,6 +608,15 @@ impl TestProps {
(_, None) => {} (_, None) => {}
} }
} }
pub fn pass_mode(&self, config: &Config) -> Option<PassMode> {
if !self.ignore_pass {
if let (mode @ Some(_), Some(_)) = (config.force_pass_mode, self.pass_mode) {
return mode;
}
}
self.pass_mode
}
} }
fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) { fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {

View file

@ -328,7 +328,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
filter_exact: matches.opt_present("exact"), filter_exact: matches.opt_present("exact"),
force_pass_mode: matches.opt_str("pass").map(|mode| force_pass_mode: matches.opt_str("pass").map(|mode|
mode.parse::<PassMode>() mode.parse::<PassMode>()
.unwrap_or_else(|_| panic!("unknown `--pass` option `{}` given.", mode)) .unwrap_or_else(|_| panic!("unknown `--pass` option `{}` given", mode))
), ),
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)), logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
runtool: matches.opt_str("runtool"), runtool: matches.opt_str("runtool"),

View file

@ -211,7 +211,6 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
props: &props, props: &props,
testpaths, testpaths,
revision: revision, revision: revision,
is_aux: false,
}; };
create_dir_all(&cx.output_base_dir()).unwrap(); create_dir_all(&cx.output_base_dir()).unwrap();
@ -230,7 +229,6 @@ pub fn run(config: Config, testpaths: &TestPaths, revision: Option<&str>) {
props: &revision_props, props: &revision_props,
testpaths, testpaths,
revision: Some(revision), revision: Some(revision),
is_aux: false,
}; };
rev_cx.run_revision(); rev_cx.run_revision();
} }
@ -262,7 +260,7 @@ pub fn compute_stamp_hash(config: &Config) -> String {
env::var_os("PYTHONPATH").hash(&mut hash); env::var_os("PYTHONPATH").hash(&mut hash);
} }
if let Ui | RunPass = config.mode { if let Ui | RunPass | Incremental = config.mode {
config.force_pass_mode.hash(&mut hash); config.force_pass_mode.hash(&mut hash);
} }
@ -274,7 +272,6 @@ struct TestCx<'test> {
props: &'test TestProps, props: &'test TestProps,
testpaths: &'test TestPaths, testpaths: &'test TestPaths,
revision: Option<&'test str>, revision: Option<&'test str>,
is_aux: bool,
} }
struct DebuggerCommands { struct DebuggerCommands {
@ -316,18 +313,13 @@ impl<'test> TestCx<'test> {
} }
} }
fn effective_pass_mode(&self) -> Option<PassMode> { fn pass_mode(&self) -> Option<PassMode> {
if !self.props.ignore_pass { self.props.pass_mode(self.config)
if let (mode @ Some(_), Some(_)) = (self.config.force_pass_mode, self.props.pass_mode) {
return mode;
}
}
self.props.pass_mode
} }
fn should_run_successfully(&self) -> bool { fn should_run_successfully(&self) -> bool {
match self.config.mode { match self.config.mode {
RunPass | Ui => self.effective_pass_mode() == Some(PassMode::Run), RunPass | Ui => self.pass_mode() == Some(PassMode::Run),
mode => panic!("unimplemented for mode {:?}", mode), mode => panic!("unimplemented for mode {:?}", mode),
} }
} }
@ -337,7 +329,7 @@ impl<'test> TestCx<'test> {
CompileFail => false, CompileFail => false,
RunPass => true, RunPass => true,
JsDocTest => true, JsDocTest => true,
Ui => self.props.pass_mode.is_some(), Ui => self.pass_mode().is_some(),
Incremental => { Incremental => {
let revision = self.revision let revision = self.revision
.expect("incremental tests require a list of revisions"); .expect("incremental tests require a list of revisions");
@ -345,7 +337,7 @@ impl<'test> TestCx<'test> {
true true
} else if revision.starts_with("cfail") { } else if revision.starts_with("cfail") {
// FIXME: would be nice if incremental revs could start with "cpass" // FIXME: would be nice if incremental revs could start with "cpass"
self.props.pass_mode.is_some() self.pass_mode().is_some()
} else { } else {
panic!("revision name must begin with rpass, rfail, or cfail"); panic!("revision name must begin with rpass, rfail, or cfail");
} }
@ -1356,7 +1348,7 @@ impl<'test> TestCx<'test> {
fn check_error_patterns(&self, output_to_check: &str, proc_res: &ProcRes) { fn check_error_patterns(&self, output_to_check: &str, proc_res: &ProcRes) {
debug!("check_error_patterns"); debug!("check_error_patterns");
if self.props.error_patterns.is_empty() { if self.props.error_patterns.is_empty() {
if self.props.pass_mode.is_some() { if self.pass_mode().is_some() {
return; return;
} else { } else {
self.fatal(&format!( self.fatal(&format!(
@ -1578,7 +1570,6 @@ impl<'test> TestCx<'test> {
props: &aux_props, props: &aux_props,
testpaths: &aux_testpaths, testpaths: &aux_testpaths,
revision: self.revision, revision: self.revision,
is_aux: true,
}; };
// Create the directory for the stdout/stderr files. // Create the directory for the stdout/stderr files.
create_dir_all(aux_cx.output_base_dir()).unwrap(); create_dir_all(aux_cx.output_base_dir()).unwrap();
@ -1748,7 +1739,6 @@ impl<'test> TestCx<'test> {
props: &aux_props, props: &aux_props,
testpaths: &aux_testpaths, testpaths: &aux_testpaths,
revision: self.revision, revision: self.revision,
is_aux: true,
}; };
// Create the directory for the stdout/stderr files. // Create the directory for the stdout/stderr files.
create_dir_all(aux_cx.output_base_dir()).unwrap(); create_dir_all(aux_cx.output_base_dir()).unwrap();
@ -1989,8 +1979,7 @@ impl<'test> TestCx<'test> {
} }
} }
let pass_mode = if self.is_aux { self.props.pass_mode } else { self.effective_pass_mode() }; if let Some(PassMode::Check) = self.pass_mode() {
if let Some(PassMode::Check) = pass_mode {
rustc.args(&["--emit", "metadata"]); rustc.args(&["--emit", "metadata"]);
} }
@ -2728,7 +2717,6 @@ impl<'test> TestCx<'test> {
props: &revision_props, props: &revision_props,
testpaths: self.testpaths, testpaths: self.testpaths,
revision: self.revision, revision: self.revision,
is_aux: false,
}; };
if self.config.verbose { if self.config.verbose {