-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live output from --show-output-of-passing-tests
#847
Comments
Implementing this would probably require deep changes, as the buffering happens on multiple levels. Additionally, the formatters would need to be adapted, as their output is not consistent with this requirement. |
We're also running into this problem, especially for calling longer running tests (sometimes up to 1 hour). |
Without knowing anything about Bats internals or exotic options, I find it hard to understand how this could require deep changes. The text I want to see is already being streamed to a file in real time, so any questions of buffering are already resolved by that point. I just want an option for that stream to be copied to stderr. No special formatting, just exactly what is in that file. There is a workaround, it is just ugly and fragile (for example it presumes that the container/VM is only running one Bats test at a time, and leaves a stopped process behind): (sleep 10; tail -f $(ls -1 /tmp/bats-run-*/bats.*.out | tail -1)) &
bats x.sh --report-formatter junit --output surefire If the test fails its output is repeated which is not ideal but tolerable. I did not find any option opposite to |
Sadly, this workaround did not work. The files in |
Maybe you are passing some options which block streaming output even to the file? I tested the sample test script given in the issue description with this workaround using Bats 1.10.0. (In a terminal, in case it matters.) |
I tried to implement something like that some time ago and then opted for allowing CTRL+C as a quick fix workaround. In essence, the problem lies in multiple layers of caching which are not necessarily file based. Allowing to print as we go would require deep changes in the way Bats' internals communicate right now. Basically, we have each layer (exec-test, exec-files, exec-suite) do their own caching/forwarding to the (report-)formatter. To achieve what you want here, we would need to let the formatter do the caching. This might not even be that complicated but I don't think this is as high of a priority and my capacity for this project is severely limited right now. |
I tried with Bats 1.11.0 running in a container - for each spec file in a folder:
To inspect the output, I docker exec'ed into the container. I can see that the test is being ran but no output :) |
Maybe that breaks the workaround just by creating multiple out files? The following seems to print output at least for a single test and in a terminal: diff --git a/libexec/bats-core/bats-exec-test b/libexec/bats-core/bats-exec-test
index 1289446..2c5b9ee 100755
--- a/libexec/bats-core/bats-exec-test
+++ b/libexec/bats-core/bats-exec-test
@@ -349,11 +349,12 @@ bats_perform_test() {
fi
get_mills_since_epoch BATS_TEST_START_TIME
+ set -o pipefail
{
bats_set_stacktrace_limit
setup "$@"
"$@"
- } >>"$BATS_OUT" 2>&1 4>&1
+ } 2>&1 4>&1 | tee /dev/stderr >>"$BATS_OUT"
BATS_TEST_COMPLETED=1
# shellcheck disable=SC2064 Might not work from a ttyless CI build, and would surely need to be refined to be enabled by an option, display (live) output from setup/teardown phases, etc. |
Is your feature request related to a problem? Please describe.
--show-output-of-passing-tests
displays test output but only after the test completes. For tests which normally take many minutes to complete, or which appear to be hung, it is therefore difficult to tell what is going on. For example you may be checking a build log in a CI system to see if your new test is actually progressing or got stuck somewhere, but there is no way to see that until it completes (or times out, or is aborted).Example:
run as
initially prints only the test name; the full output only appears 30s later, all at once.
Describe the solution you'd like
Output should be streamed to the
bats
stdout/stderr as it is processed.Describe alternatives you've considered
tail -f /tmp/bats-run-<something>/bats.<something>.out
can be used as a workaround, but the filenames are unpredictable, and you cannot use a wildcard because there are two*.out
files, one of which is empty AFAICT.The text was updated successfully, but these errors were encountered: