diff options
| author | Tinco Andringa <mail@tinco.nl> | 2018-09-10 12:28:30 +0200 |
|---|---|---|
| committer | Tinco Andringa <mail@tinco.nl> | 2018-09-10 12:33:39 +0200 |
| commit | 518bcffa317db45e437a5e425fb3d7f29e6cab0c (patch) | |
| tree | 311e22896e525be1cbc527cde9d27f7a0b406239 | |
| parent | ca901a187c9104b91de0d2370025024397c90832 (diff) | |
| download | rust-518bcffa317db45e437a5e425fb3d7f29e6cab0c.tar.gz rust-518bcffa317db45e437a5e425fb3d7f29e6cab0c.zip | |
refactor so that it's no longer possible to call print_source incorrectly
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4cc63640d14..c9ddd5f00f2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -242,7 +242,7 @@ struct DebuggerCommands { enum ReadFrom { Path, - Stdin, + Stdin(String), } impl<'test> TestCx<'test> { @@ -426,11 +426,14 @@ impl<'test> TestCx<'test> { round, self.revision ), ); - 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); + let read_from = if round == 0 { + ReadFrom::Path + } else { + ReadFrom::Stdin(srcs[round].to_owned()) + }; + let proc_res = self.print_source(read_from, + &self.props.pretty_mode); if !proc_res.status.success() { self.fatal_proc_rec( &format!( @@ -485,7 +488,7 @@ impl<'test> TestCx<'test> { } // additionally, run `--pretty expanded` and try to build it. - let proc_res = self.print_source(srcs[round].clone(), "expanded", ReadFrom::Path); + let proc_res = self.print_source(ReadFrom::Path, "expanded"); if !proc_res.status.success() { self.fatal_proc_rec("pretty-printing (expanded) failed", &proc_res); } @@ -503,10 +506,10 @@ impl<'test> TestCx<'test> { } } - fn print_source(&self, src: String, pretty_type: &str, read_from: ReadFrom) -> ProcRes { + fn print_source(&self, read_from: ReadFrom, pretty_type: &str) -> ProcRes { let aux_dir = self.aux_output_dir_name(); let input: &str = match read_from { - ReadFrom::Stdin => "-", + ReadFrom::Stdin(_) => "-", ReadFrom::Path => self.testpaths.file.to_str().unwrap(), }; @@ -521,8 +524,8 @@ impl<'test> TestCx<'test> { .args(&self.props.compile_flags) .envs(self.props.exec_env.clone()); - let src_to_read = match read_from { - ReadFrom::Stdin => Some(src), + let src = match read_from { + ReadFrom::Stdin(src) => Some(src), ReadFrom::Path => None }; @@ -530,7 +533,7 @@ impl<'test> TestCx<'test> { rustc, self.config.compile_lib_path.to_str().unwrap(), Some(aux_dir.to_str().unwrap()), - src_to_read, + src, ) } |
