Skip to content

Commit 2ddf0ca

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 5b9564a commit 2ddf0ca

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
@@ -2957,7 +2957,8 @@ pub struct ProcRes {
29572957
}
29582958

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

2976-
println!(
2977+
format!(
29772978
"status: {}\ncommand: {}\n{}\n{}\n",
29782979
self.status,
29792980
self.cmdline,
29802981
render("stdout", &self.stdout),
29812982
render("stderr", &self.stderr),
2982-
);
2983+
)
29832984
}
29842985

29852986
pub fn fatal(&self, err: Option<&str>, on_failure: impl FnOnce()) -> ! {
29862987
if let Some(e) = err {
29872988
println!("\nerror: {}", e);
29882989
}
2989-
self.print_info();
2990+
println!("{}", self.format_info());
29902991
on_failure();
29912992
// Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
29922993
// 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)