Closed noel-yap closed 2 years ago
It happens when there's at least one bats file that passes.
I found the culprit. Some of my tests have a trap
to remove temporary files. If I comment out the trap
, bazel
fails as expected.
I'm still unable to fix this, though, since trap 'es=$?; rm -rf -- "${tmpdir}"; exit ${es}' INT TERM HUP EXIT
isn't causing bazel
to fail.
IIUC, the root issue here is that you create a temporary directory for your tests. It then interacts badly with bazel's test result detection.
This should not be necessary in bazel: when running the tests, bazel will give you an env variable TEST_TMPDIR
that you can use for a hermetic writeable area. I understand that this can be a confusing situation when you want to use both bazel and "vanilla" test invocations.
See: https://docs.bazel.build/versions/main/test-encyclopedia.html#initial-conditions for details.
Within a test it may make sense to check whether you are running under bazel, and then use the provided temporary directory instead of managing your own.
I'm assuming that this result came out of using the test fixture in a way that was not intended. Closing for now, but feel free to reopen if you disagree.
I'm seeing the following output:
What can cause something like this?