From 81a660ee6d0147c96ee5a1c36fe1d424f7f35832 Mon Sep 17 00:00:00 2001 From: Ryan Johnson Date: Fri, 1 Nov 2024 11:08:57 -0700 Subject: [PATCH] improve output on test compilation failure --- tests/tests.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/tests.rs b/tests/tests.rs index 41162237..97bdf21f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -186,7 +186,21 @@ fn compile( println!("Running: {:?}", command); let out = command.output().expect("failed to compile"); - assert!(out.status.success(), "Output failed to compile: {:?}", out); + if !out.status.success() { + let stdout = match str::from_utf8(&out.stdout) { + Ok(s) => s.to_string(), + Err(_) => format!("{:?}", out.stdout), + }; + let stderr = match str::from_utf8(&out.stderr) { + Ok(s) => s.to_string(), + Err(_) => format!("{:?}", out.stderr), + }; + println!("Output failed to compile: {:?}", out.status); + println!("=== STDOUT ===\n{}", stdout); + println!("=== STDERR ===\n{}", stderr); + println!("=============="); + assert!(out.status.success()); + } if object.exists() { fs::remove_file(object).unwrap();