Skip to content

Commit

Permalink
show stdout,stderr
Browse files Browse the repository at this point in the history
Signed-off-by: xxchan <[email protected]>
  • Loading branch information
xxchan committed Apr 11, 2024
1 parent 40814ad commit 4719709
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.20.0] - 2024-04-08

* Show stdout, stderr when `system` command fails.
* Support matching stdout for `system`
```
system ok
Expand Down
16 changes: 9 additions & 7 deletions sqllogictest/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,14 +642,12 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
cmd.arg("-c").arg(command);
cmd
};
if expected_stdout.is_some() {
// only capture stdout if there's an expected value
cmd.stdout(std::process::Stdio::piped());
}
cmd.stdout(std::process::Stdio::piped());
cmd.stderr(std::process::Stdio::piped());
let result = D::run_command(cmd).await;
#[derive(thiserror::Error, Debug)]
#[error("process exited unsuccessfully: {0}")] // message from unstable `ExitStatusError`
struct SystemError(ExitStatus);
#[error("process exited unsuccessfully: {0}\nstdout: {1}\nstderr: {2}")]
struct SystemError(ExitStatus, String, String);

let mut stdout = None;
let error: Option<AnyError> = match result {
Expand All @@ -660,7 +658,11 @@ impl<D: AsyncDB, M: MakeConnection<Conn = D>> Runner<D, M> {
}
None
} else {
Some(Arc::new(SystemError(output.status)))
Some(Arc::new(SystemError(
output.status,
String::from_utf8_lossy(&output.stdout).to_string(),
String::from_utf8_lossy(&output.stderr).to_string(),
)))
}
}
Err(e) => Some(Arc::new(e)),
Expand Down

0 comments on commit 4719709

Please sign in to comment.