Fix most test output (but not termcolor)

This commit is contained in:
Lucien Greathouse
2021-11-22 13:59:12 -05:00
parent 9b22545842
commit e8afa03f7b
2 changed files with 20 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
use std::{ use std::{
fs, io, fs,
io::{self, Read},
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Child, process::Child,
}; };
@@ -50,5 +51,17 @@ pub struct KillOnDrop(pub Child);
impl Drop for KillOnDrop { impl Drop for KillOnDrop {
fn drop(&mut self) { fn drop(&mut self) {
let _ = self.0.kill(); let _ = self.0.kill();
if let Some(mut stdout) = self.0.stdout.take() {
let mut output = Vec::new();
let _ = stdout.read_to_end(&mut output);
print!("{}", String::from_utf8_lossy(&output));
}
if let Some(mut stderr) = self.0.stderr.take() {
let mut output = Vec::new();
let _ = stderr.read_to_end(&mut output);
eprint!("{}", String::from_utf8_lossy(&output));
}
} }
} }

View File

@@ -63,7 +63,7 @@ fn run_build_test(test_name: &str) {
let output_dir = tempdir().expect("couldn't create temporary directory"); let output_dir = tempdir().expect("couldn't create temporary directory");
let output_path = output_dir.path().join(format!("{}.rbxmx", test_name)); let output_path = output_dir.path().join(format!("{}.rbxmx", test_name));
let status = Command::new(ROJO_PATH) let output = Command::new(ROJO_PATH)
.args(&[ .args(&[
"build", "build",
input_path.to_str().unwrap(), input_path.to_str().unwrap(),
@@ -72,10 +72,13 @@ fn run_build_test(test_name: &str) {
]) ])
.env("RUST_LOG", "error") .env("RUST_LOG", "error")
.current_dir(working_dir) .current_dir(working_dir)
.status() .output()
.expect("Couldn't start Rojo"); .expect("Couldn't start Rojo");
assert!(status.success(), "Rojo did not exit successfully"); print!("{}", String::from_utf8_lossy(&output.stdout));
eprint!("{}", String::from_utf8_lossy(&output.stderr));
assert!(output.status.success(), "Rojo did not exit successfully");
let contents = fs::read_to_string(&output_path).expect("Couldn't read output file"); let contents = fs::read_to_string(&output_path).expect("Couldn't read output file");