Skip to content

Isolated temp dir per run #283

@dimo414

Description

@dimo414

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions