The README points to BATS_TMPDIR as a "location to a directory that may be used to store temporary files", but currently it's (typically) just /tmp or $TMPDIR, meaning that anything written to that directory will affect subsequent runs.
BATS itself appears to instead use BATS_TMPNAME which is keyed off the PID (which still isn't safe, as the OS will reuse PIDs over time), but it's not clear whether users are supposed to use BATS_TMPNAME or if it's an implementation detail.
I would suggest providing a different variable, e.g. BATS_TEST_TMP, that is unique per-run, and documenting that in the README instead of BATS_TMPDIR. I'd also suggest changing BATS_TMPNAME to not (only) rely on the PID, but I'm not sure if there are additional constraints with that - BATS_PARENT_TMPNAME makes me suspicious parts of BATS currently relies on this naming scheme.
The README points to
BATS_TMPDIRas a "location to a directory that may be used to store temporary files", but currently it's (typically) just/tmpor$TMPDIR, meaning that anything written to that directory will affect subsequent runs.BATS itself appears to instead use
BATS_TMPNAMEwhich is keyed off the PID (which still isn't safe, as the OS will reuse PIDs over time), but it's not clear whether users are supposed to useBATS_TMPNAMEor if it's an implementation detail.I would suggest providing a different variable, e.g.
BATS_TEST_TMP, that is unique per-run, and documenting that in the README instead ofBATS_TMPDIR. I'd also suggest changingBATS_TMPNAMEto not (only) rely on the PID, but I'm not sure if there are additional constraints with that -BATS_PARENT_TMPNAMEmakes me suspicious parts of BATS currently relies on this naming scheme.