You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
Using set -x in TAP mode breaks bats scripts if the test fails. The cause of the failure is that the set -x debug output interleaves with the regular output and breaks bats' parsing for extraction of the failure reason.
This problem can be fixed without modifications to bats. Bash allows setting the file descriptor written to by set -x with the variable BASH_XTRACEFD. To get the set -x debug output visible within a TAP mode bats test, set BASH_XTRACEFD to file descriptor 3. For example:
test.bats
#!/usr/bin/env bats
@test "foo" {
BASH_XTRACEFD=3
set -x
ls $HOME && 0
}
and execute this with
bats -t test.bats
Please document this somewhere, the technique is very useful for troubleshooting bats scripts.
The text was updated successfully, but these errors were encountered:
Using
set -x
in TAP mode breaks bats scripts if the test fails. The cause of the failure is that theset -x
debug output interleaves with the regular output and breaks bats' parsing for extraction of the failure reason.This problem can be fixed without modifications to bats. Bash allows setting the file descriptor written to by
set -x
with the variableBASH_XTRACEFD
. To get theset -x
debug output visible within a TAP mode bats test, setBASH_XTRACEFD
to file descriptor 3. For example:test.bats
and execute this with
Please document this somewhere, the technique is very useful for troubleshooting bats scripts.
The text was updated successfully, but these errors were encountered: