diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2018-07-17 17:00:34 +0200 |
|---|---|---|
| committer | Tinco Andringa <mail@tinco.nl> | 2018-09-10 12:33:38 +0200 |
| commit | e4f47f43a6b2c26a5eef7d4a71379c47a6ea4eaf (patch) | |
| tree | 8613335885f1cf2d9b4ef373e13dca7614f1ecd8 | |
| parent | 23ee94e92b2111a65de9b6269df858a565656ff8 (diff) | |
| download | rust-e4f47f43a6b2c26a5eef7d4a71379c47a6ea4eaf.tar.gz rust-e4f47f43a6b2c26a5eef7d4a71379c47a6ea4eaf.zip | |
Update `compiletest` so that the pretty tests only read from stdin when they *have* to.
This allows us to test expansion of files that use `mod foo;` syntax.
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 24b575aae12..261986af52f 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -240,6 +240,11 @@ struct DebuggerCommands { breakpoint_lines: Vec<usize>, } +enum ReadFrom { + Path, + Stdin, +} + impl<'test> TestCx<'test> { /// Code executed for each revision in turn (or, if there are no /// revisions, exactly once, with revision == None). @@ -421,7 +426,10 @@ impl<'test> TestCx<'test> { round, self.revision ), ); - let proc_res = self.print_source(srcs[round].to_owned(), &self.props.pretty_mode); + let read_from = if round == 0 { ReadFrom::Path } else { ReadFrom::Stdin }; + let proc_res = self.print_source(srcs[round].to_owned(), + &self.props.pretty_mode, + read_from); if !proc_res.status.success() { self.fatal_proc_rec( @@ -477,7 +485,7 @@ impl<'test> TestCx<'test> { } // additionally, run `--pretty expanded` and try to build it. - let proc_res = self.print_source(srcs[round].clone(), "expanded"); + let proc_res = self.print_source(srcs[round].clone(), "expanded", ReadFrom::Path); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res); } @@ -495,12 +503,16 @@ impl<'test> TestCx<'test> { } } - fn print_source(&self, src: String, pretty_type: &str) -> ProcRes { + fn print_source(&self, src: String, pretty_type: &str, read_from: ReadFrom) -> ProcRes { let aux_dir = self.aux_output_dir_name(); + let input: &str = match read_from { + ReadFrom::Stdin => "-", + ReadFrom::Path => self.testpaths.file.to_str().unwrap(), + }; let mut rustc = Command::new(&self.config.rustc_path); rustc - .arg("-") + .arg(input) .args(&["-Z", &format!("unpretty={}", pretty_type)]) .args(&["--target", &self.config.target]) .arg("-L") |
