Skip to content

Commit f88198e

Browse files
committed
Change ProcRes::print_info to format_info
This method now returns a string instead of printing directly to (possibly-captured) stdout.
1 parent 63f6845 commit f88198e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,7 +2958,8 @@ pub struct ProcRes {
29582958
}
29592959

29602960
impl ProcRes {
2961-
pub fn print_info(&self) {
2961+
#[must_use]
2962+
pub fn format_info(&self) -> String {
29622963
fn render(name: &str, contents: &str) -> String {
29632964
let contents = json::extract_rendered(contents);
29642965
let contents = contents.trim_end();
@@ -2974,20 +2975,20 @@ impl ProcRes {
29742975
}
29752976
}
29762977

2977-
println!(
2978+
format!(
29782979
"status: {}\ncommand: {}\n{}\n{}\n",
29792980
self.status,
29802981
self.cmdline,
29812982
render("stdout", &self.stdout),
29822983
render("stderr", &self.stderr),
2983-
);
2984+
)
29842985
}
29852986

29862987
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
29872988
if let Some(e) = err {
29882989
println!("\nerror: {}", e);
29892990
}
2990-
self.print_info();
2991+
println!("{}", self.format_info());
29912992
on_failure();
29922993
// Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
29932994
// compiletest, which is unnecessary noise.

src/tools/compiletest/src/runtest/rustdoc_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl TestCx<'_> {
3131
if !res.status.success() {
3232
self.fatal_proc_rec_with_ctx("jsondocck failed!", &res, |_| {
3333
println!("Rustdoc Output:");
34-
proc_res.print_info();
34+
println!("{}", proc_res.format_info());
3535
})
3636
}
3737

0 commit comments

Comments
 (0)