Skip to content

Commit bb7ab5c

Browse files
committed
some tidy fixes
1 parent 4023f05 commit bb7ab5c

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ impl CompareMode {
106106
CompareMode::Nll => "nll"
107107
}
108108
}
109+
110+
pub fn parse(s: String) -> CompareMode {
111+
match s.as_str() {
112+
"nll" => CompareMode::Nll,
113+
x => panic!("unknown --compare-mode option: {}", x),
114+
}
115+
}
109116
}
110117

111118
#[derive(Clone)]
@@ -246,7 +253,11 @@ pub struct TestPaths {
246253
}
247254

248255
/// Used by `ui` tests to generate things like `foo.stderr` from `foo.rs`.
249-
pub fn expected_output_path(testpaths: &TestPaths, revision: Option<&str>, compare_mode: &Option<CompareMode>, kind: &str) -> PathBuf {
256+
pub fn expected_output_path(testpaths: &TestPaths,
257+
revision: Option<&str>,
258+
compare_mode: &Option<CompareMode>,
259+
kind: &str) -> PathBuf {
260+
250261
assert!(UI_EXTENSIONS.contains(&kind));
251262
let mut parts = Vec::new();
252263

src/tools/compiletest/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
327327
quiet: matches.opt_present("quiet"),
328328
color,
329329
remote_test_client: matches.opt_str("remote-test-client").map(PathBuf::from),
330-
compare_mode: matches.opt_str("compare-mode").and_then(|x| if x == "nll" { Some(CompareMode::Nll) } else { panic!("Unknown compare-mode {}", x) }),
330+
compare_mode: matches.opt_str("compare-mode").map(CompareMode::parse),
331331

332332
cc: matches.opt_str("cc").unwrap(),
333333
cxx: matches.opt_str("cxx").unwrap(),
@@ -696,7 +696,10 @@ fn up_to_date(config: &Config, testpaths: &TestPaths, props: &EarlyProps) -> boo
696696
// UI test files.
697697
for extension in UI_EXTENSIONS {
698698
for revision in &props.revisions {
699-
let path = &expected_output_path(testpaths, Some(revision), &config.compare_mode, extension);
699+
let path = &expected_output_path(testpaths,
700+
Some(revision),
701+
&config.compare_mode,
702+
extension);
700703
inputs.push(mtime(path));
701704
}
702705

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,11 @@ impl<'test> TestCx<'test> {
28032803
}
28042804

28052805
fn expected_output_path(&self, kind: &str) -> Result<PathBuf, String> {
2806-
let mut path = expected_output_path(&self.testpaths, self.revision, &self.config.compare_mode, kind);
2806+
let mut path = expected_output_path(&self.testpaths,
2807+
self.revision,
2808+
&self.config.compare_mode,
2809+
kind);
2810+
28072811
if !path.exists() && self.config.compare_mode.is_some() {
28082812
// fallback!
28092813
path = expected_output_path(&self.testpaths, self.revision, &None, kind);

0 commit comments

Comments
 (0)