mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-23 05:51:39 +00:00
Improve error handling in TestServeSession for Rojo process
- Enhanced the error handling logic when the Rojo process exits unexpectedly by capturing and displaying stderr output. This provides better context for debugging failures during test execution. - Updated the process spawning to pipe stderr, allowing for more informative panic messages when the process fails.
This commit is contained in:
parent
df06fd0852
commit
b1aa2a384f
1 changed files with 13 additions and 2 deletions
|
|
@ -1,8 +1,9 @@
|
|||
use std::{
|
||||
fmt::Write as _,
|
||||
fs,
|
||||
io::Read as _,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
process::{Command, Stdio},
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
thread,
|
||||
time::Duration,
|
||||
|
|
@ -108,6 +109,7 @@ impl TestServeSession {
|
|||
port_string.as_str(),
|
||||
])
|
||||
.current_dir(working_dir)
|
||||
.stderr(Stdio::piped())
|
||||
.spawn()
|
||||
.expect("Couldn't start Rojo");
|
||||
|
||||
|
|
@ -132,7 +134,16 @@ impl TestServeSession {
|
|||
|
||||
for i in 1..=MAX_TRIES {
|
||||
match self.rojo_process.0.try_wait() {
|
||||
Ok(Some(status)) => panic!("Rojo process exited with status {}", status),
|
||||
Ok(Some(status)) => {
|
||||
let mut stderr_output = String::new();
|
||||
if let Some(mut stderr) = self.rojo_process.0.stderr.take() {
|
||||
let _ = stderr.read_to_string(&mut stderr_output);
|
||||
}
|
||||
panic!(
|
||||
"Rojo process exited with status {}\nstderr:\n{}",
|
||||
status, stderr_output
|
||||
);
|
||||
}
|
||||
Ok(None) => { /* The process is still running, as expected */ }
|
||||
Err(err) => panic!("Failed to wait on Rojo process: {}", err),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue