When the zebrad acceptance tests fail, we only see the acceptance test output. But sometimes we need to see the child process output to diagnose the issue.
Here's an example of a test failure where the child's output would be useful:
assert!(output.was_killed())We already wait on the child's output on success. We just need to make sure that we log its output every time we are about to fail a test.
Surprised it isn't already setup to do this tbh, that's just an oversight on my part.
This is not totally clear to me, maybe because the link do not have a failure anymore so i cant see how the issue was exactly.
By what i can see any test who calls the assert_success() when the child failed will display the child error in stdout. The same with assert_failure(); any test who calls assert_failure() on a success will display child error in stdout.
For instance, calling success in a failure will display something as:
...
running 1 test
Error:
0: command exited unsuccessfully
Command:
"/home/oxarbitrage/zebra/issue944/zebra/target/debug/zebrad" "dsds"
Exit Code: 1
Stdout:
error: unrecognized command `dsds`
zebrad 3.0.0-alpha.0
Zcash Foundation <[email protected]>
FLAGS:
-c, --config CONFIG path to configuration file
-h, --help print help message
-v, --verbose be verbose
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
The application panicked (crashed).
Message: assertion failed: `(left == right)`
left: `1`,
right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure
Location: <::std::macros::panic macros>:5
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
...
Any additional comment to help clarify is appreciated.
perhaps it was one of the stdout_* functions? Those currently only capture stdout and the command as sections, but not stderr.
Sorry, I linked to the CI, but it looks like that run has been deleted. I think I also named the wrong function.
From what I remember, the child panicked, and failed assert!(output.was_killed()).
(But let's check that all the test child functions show the child's output on error.)
(But let's check that all the test child functions show the child's output on error.)
the best way to do this would probably be to remove all the assert!s in our tests that act on conditions like was_killed and instead change those conditional fns to return Result<(), Report> so we can do output.was_killed()? and have was_killed bundle the appropriate context with the report before returning it.
Thank you both, ill see what i can do.
Most helpful comment
the best way to do this would probably be to remove all the
assert!s in our tests that act on conditions likewas_killedand instead change those conditional fns to returnResult<(), Report>so we can dooutput.was_killed()?and havewas_killedbundle the appropriate context with the report before returning it.