--show-output-of-passing-tests
does show no run
$output
on passing tests
#799
Labels
Component: Docs
Priority: Medium
Wrong or misleading documentation, broken behavior with workaround
Size: Medium
Changes in the same file
Type: Bug
Thank you for the great work on this important project.
Summary
I have seen output (stdout + stderr) not being captured and outputted as expected for passing tests when using
--show-output-of-passing-tests
. The problem is reflected in the temp dir where captured output is supposed to reside in the filesstdout
andstderr
which are for passing tests unexpectedly empty.--print-output-on-failure
seems to largely work, but may store stderr as stdout.--gather-test-outputs-in <directory>
in my case generates empty files, but I suppose this is the same problem as with--show-output-of-passing-tests
in my case, so let's focus on that.Something might be special about my environment, but I think it's not too special.
Detail
Repro (a little big, but it's what I have for now):
This should lead to a passing test suite. Output for me:
Now edit
Makefile
and change:(the removals are for keeping things simple).
Run
make clitests
again. The test suite still passes, but the expected output is not emitted, the bats output does (on my machine) not change compared to not providing--show-output-of-passing-tests
.Yes, this runs bats in a container, and it mounts the host /tmp into the container /tmp. I hope this is nothing too concerning.
By inspecting the tmp dir after the test run we can see that the output indeed wasn't captured properly:
Expected: in this case I expect
stderr
to be filled with log statements (Python's default logging behavior: writes to stderr), andstdout
would be expected to be empty (the tested program does not write to stdout).Observed:
stderr
is empty (unexpected) andstdout
contains output from the bats test runner (that seems to be fine. too). That is, stderr of the tested program is 'lost'. However, that's not specific to stderr. I tried emitting on stdout, too, it's then also not captured (not appearing in thestdout
file).What's interesting is that in this very setup
--print-output-on-failure
seems to work almost fine for me: in case of a failure, the output is generally captured and printed.That is, output capturing is not generally broken in my case, but there seems to be an asymmetry between
--print-output-on-failure
and--show-output-of-passing-tests
.Peculiarity with
--print-output-on-failure
when looking in more detail: stderr is captured as stdout:That last bit is generated by
sys.exit("msg emitted to stderr")
in Python which writes tostderr
. Thestderr
file as created by bats is empty:(as expected, kind of, because this seems to to have been redirected to the file called
stdout
; but that redirection itself is at least unexpected to me).Environment (please complete the following information):
As this is a containerized setup you can see how it's created. For a quick overview I have added
cat /etc/*-release && bash --version
to the cmd run in the container right before invoking bats:Additional context
I rarely get a race condition hitting in while executing this test suite, where a mv/rename after creating a file doesn't reliably work:
If you get this, please re-run. I sincerely do hope this is an independent issue (whereas I fear this is some tmpfs magic doing terrible things).
The text was updated successfully, but these errors were encountered: