Isolate stubs to each individual test #28
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I ran into a similar issue as #14 when trying to run bats with
--jobs <n>. On investigation it seems this is happening because eachbinstubcreated was being placed in${BATS_RUN_TMPDIR}/bin. This directory is common to all tests so when running in parallelstub,unstub(andbinstubfor recording test runs) are all racing to operate on the same state.Moving the stubs into
${BATS_TEST_TMPDIR}/binkeeps them isolated to each individual test.The unit test I've added is a bit of a mindfuck sorry but it does the trick. It fails without the one-line fix I've made in
stub.bash.One thing I'm not sure about is whether I've not thought of scenarios where the stubs might be expected to be shared between tests. This sounds like an antipattern to me but if it sounds like it might be a thing then maybe this is a breaking change 🤷🏻
I did see this line has caused grief before #19. I think this change is an evolution of that cc @KlfJoat @pzeballos
resolves #14