Skip to content

Commit

Permalink
some tidy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
memoryleak47 committed Mar 23, 2018
1 parent 4023f05 commit bb7ab5c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/tools/compiletest/src/common.rs
Expand Up @@ -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)]
Expand Down Expand Up @@ -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();

Expand Down
7 changes: 5 additions & 2 deletions src/tools/compiletest/src/main.rs
Expand Up @@ -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(),
Expand Down Expand Up @@ -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));
}

Expand Down
6 changes: 5 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Expand Up @@ -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);
Expand Down

0 comments on commit bb7ab5c

Please sign in to comment.