Skip to content

Conversation

@jgrigg
Copy link

@jgrigg jgrigg commented Nov 24, 2025

I ran into a similar issue as #14 when trying to run bats with --jobs <n>. On investigation it seems this is happening because each binstub created was being placed in${BATS_RUN_TMPDIR}/bin. This directory is common to all tests so when running in parallel stub, unstub (and binstub for recording test runs) are all racing to operate on the same state.

Moving the stubs into ${BATS_TEST_TMPDIR}/bin keeps 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

@jgrigg
Copy link
Author

jgrigg commented Nov 24, 2025

Look what I found in the OG repo! jasonkarns#56

On that front It looks like that repo has been moving along quite a bit (as has this fork but in different directions). Have you guys ever had a chat with @jasonkarns around reincorporating all the changes? Assuming a maintenance model that doesn't decay can be found, I'd be open to helping make this happen. Getting this into bats-core in the long run and packaging it up in the docker image would be pretty great for everyone's ci pipelines #22

Copy link

@toote toote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate the fix 😃

@pzeballos pzeballos merged commit 65ff193 into buildkite-plugins:master Nov 25, 2025
1 check failed
@jgrigg jgrigg deleted the concurrent_stubs branch November 26, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants