diff options
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 13 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 7 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 6 |
3 files changed, 22 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 4a1c7b49953..41fc67a66f4 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -106,6 +106,13 @@ impl CompareMode { CompareMode::Nll => "nll" } } + + pub fn parse(s: String) -> CompareMode { + match s.as_str() { + "nll" => CompareMode::Nll, + x => panic!("unknown --compare-mode option: {}", x), + } + } } #[derive(Clone)] @@ -246,7 +253,11 @@ pub struct TestPaths { } /// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`. -pub fn expected_output_path(testpaths: &TestPaths, revision: Option<&str>, compare_mode: &Option<CompareMode>, kind: &str) -> PathBuf { +pub fn expected_output_path(testpaths: &TestPaths, + revision: Option<&str>, + compare_mode: &Option<CompareMode>, + kind: &str) -> PathBuf { + assert!(UI_EXTENSIONS.contains(&kind)); let mut parts = Vec::new(); diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 7c676fe939d..795ad0c74b7 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -327,7 +327,7 @@ pub fn parse_config(args: Vec<String>) -> Config { quiet: matches.opt_present("quiet"), color, remote_test_client: matches.opt_str("remote-test-client").map(PathBuf::from), - compare_mode: matches.opt_str("compare-mode").and_then(|x| if x == "nll" { Some(CompareMode::Nll) } else { panic!("Unknown compare-mode {}", x) }), + compare_mode: matches.opt_str("compare-mode").map(CompareMode::parse), cc: matches.opt_str("cc").unwrap(), cxx: matches.opt_str("cxx").unwrap(), @@ -696,7 +696,10 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo // UI test files. for extension in UI_EXTENSIONS { for revision in &props.revisions { - let path = &expected_output_path(testpaths, Some(revision), &config.compare_mode, extension); + let path = &expected_output_path(testpaths, + Some(revision), + &config.compare_mode, + extension); inputs.push(mtime(path)); } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 8d15ba06e0a..540ff13eae5 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2803,7 +2803,11 @@ impl<'test> TestCx<'test> { } fn expected_output_path(&self, kind: &str) -> Result<PathBuf, String> { - let mut path = expected_output_path(&self.testpaths, self.revision, &self.config.compare_mode, kind); + let mut path = expected_output_path(&self.testpaths, + self.revision, + &self.config.compare_mode, + kind); + if !path.exists() && self.config.compare_mode.is_some() { // fallback! path = expected_output_path(&self.testpaths, self.revision, &None, kind); |
