diff options
| author | bors <bors@rust-lang.org> | 2018-04-19 11:13:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-19 11:13:10 +0000 |
| commit | 8a28d94ea1b6c19b7e1d41ef9b33ccb73951f654 (patch) | |
| tree | ca79b860528005be4f468f665f1270c1474241b0 /src/tools | |
| parent | 5fe6b58dfc5ef9bb5dbfba9cf74aa9293a33e7b2 (diff) | |
| parent | 33bcb4ed16b01abeaa762c99e452da82c9c6275f (diff) | |
Auto merge of #49900 - pnkfelix:compare-mode-nll-followup-3, r=nikomatsakis
Add src/test/ui regression testing for NLL This PR changes `x.py test` so that when you are running the `ui` test suite, it will also always run `compiletest` in the new `--compare-mode=nll`, which just double-checks that when running under the experimental NLL mode, the output matches the `<source-name>.nll.stderr` file, if present. In order to reduce the chance of a developer revolt in response to this change, this PR also includes some changes to make the `--compare-mode=nll` more user-friendly: 1. It now generates nll-specific .stamp files, and uses them (so that repeated runs can reuse previously cached results). 2. Each line of terminal output distinguishes whether we are running under `--compare-mode=nll` by printing with the prefix `[ui (nll)]` instead of just the prefix `[ui]`. Subtask of rust-lang/rust#48879
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/compiletest/src/common.rs | 2 | ||||
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 17 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 10 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 41fc67a66f4..365b47447f2 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -101,7 +101,7 @@ pub enum CompareMode { } impl CompareMode { - fn to_str(&self) -> &'static str { + pub(crate) fn to_str(&self) -> &'static str { match *self { CompareMode::Nll => "nll" } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index ae4f4aa4046..37f7af0abe8 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -626,7 +626,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn // Debugging emscripten code doesn't make sense today let ignore = early_props.ignore - || (!up_to_date(config, testpaths, &early_props) && config.compare_mode.is_none()) + || !up_to_date(config, testpaths, &early_props) || (config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) && config.target.contains("emscripten"); @@ -642,10 +642,15 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn } fn stamp(config: &Config, testpaths: &TestPaths) -> PathBuf { + let mode_suffix = match config.compare_mode { + Some(ref mode) => format!("-{}", mode.to_str()), + None => format!(""), + }; let stamp_name = format!( - "{}-{}.stamp", + "{}-{}{}.stamp", testpaths.file.file_name().unwrap().to_str().unwrap(), - config.stage_id + config.stage_id, + mode_suffix ); config .build_base @@ -728,7 +733,11 @@ pub fn make_test_name(config: &Config, testpaths: &TestPaths) -> test::TestName let path = PathBuf::from(config.src_base.file_name().unwrap()) .join(&testpaths.relative_dir) .join(&testpaths.file.file_name().unwrap()); - test::DynTestName(format!("[{}] {}", config.mode, path.display())) + let mode_suffix = match config.compare_mode { + Some(ref mode) => format!(" ({})", mode.to_str()), + None => format!(""), + }; + test::DynTestName(format!("[{}{}] {}", config.mode, mode_suffix, path.display())) } pub fn make_test_closure(config: &Config, testpaths: &TestPaths) -> test::TestFn { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index e79aefb7236..c16dbd0272a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2811,7 +2811,7 @@ impl<'test> TestCx<'test> { normalized } - fn load_expected_output(&self, kind: &str) -> String { + fn expected_output_path(&self, kind: &str) -> PathBuf { let mut path = expected_output_path(&self.testpaths, self.revision, &self.config.compare_mode, @@ -2822,6 +2822,11 @@ impl<'test> TestCx<'test> { path = expected_output_path(&self.testpaths, self.revision, &None, kind); } + path + } + + fn load_expected_output(&self, kind: &str) -> String { + let path = self.expected_output_path(kind); if path.exists() { match self.load_expected_output_from_path(&path) { Ok(x) => x, @@ -2875,7 +2880,8 @@ impl<'test> TestCx<'test> { } } - let output_file = self.output_base_name().with_extension(kind); + let expected_output_path = self.expected_output_path(kind); + let output_file = self.output_base_name().with_file_name(&expected_output_path); match File::create(&output_file).and_then(|mut f| f.write_all(actual.as_bytes())) { Ok(()) => {} Err(e) => self.fatal(&format!( |
