diff options
| author | memoryleak47 <memoryleak47@protonmail.ch> | 2018-03-23 06:10:03 +0100 |
|---|---|---|
| committer | memoryleak47 <memoryleak47@protonmail.ch> | 2018-03-23 06:10:03 +0100 |
| commit | bb7ab5c85db7954f2662e84a88610b8b39b501c7 (patch) | |
| tree | 3a25080d7f1bb2613205bd01a2f5248cc80a7525 | |
| parent | 4023f054b1830f22459b882271a8e0430da2fcb5 (diff) | |
| download | rust-bb7ab5c85db7954f2662e84a88610b8b39b501c7.tar.gz rust-bb7ab5c85db7954f2662e84a88610b8b39b501c7.zip | |
some tidy fixes
| -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); |
