Skip to content

shared locks: like LOCK_SH for HARNESS-CONFLICTS's LOCK_EX - #455

Merged
exodist merged 6 commits into
Test-More:1.0from
rjbs:non-conflict-conflict
Aug 20, 2026
Merged

exodist merged 6 commits into
Test-More:1.0from
rjbs:non-conflict-conflict

Conversation

@rjbs

@rjbs rjbs commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Right now if you have ten tests, and one of them can't run at the same time as the others, you end up putting HARNESS-CONFLICTS-WHATEVER at the top of all ten, and now they're strictly serialized.

With this branch you get HARNESS-SHARES-WHATEVER. The nine friendly tests get that, and can run alongside each other, but the greedy test keeps HARNESS-CONFLICTS-WHATEVER and now won't run with any of the others.

If you declare both in one file, it's exclusive and warns.

Bonus: tests for Test2::Harness::Runner::State

rjbs and others added 6 commits August 18, 2026 16:22
We already have HARNESS-CONFLICTS-XXX, which is effectively an exclusive
lock on the name XXX.  This is a lot better than
HARNESS-CATEGORY-ISOLATION, but it's still sometimes overkill.
Sometimes you have ten tests, and nine of them can run at once, but the
tenth can't run with any of them.  CONFLICTS would serialize all ten,
which stinks.  SHARES lets the nine run together, but not the tenth.

SHARES is the LOCK_SH to CONFLICTS' LOCK_EX.

Nothing enforces it yet, though.  This is just to parse the name into
the queue item!

A name claimed both ways in one file is almost certainly an author error, so
we warn, but just treat it as exclusive.

Co-authored-by: Claude <noreply@anthropic.com>
An exclusive claim (HARNESS-CONFLICTS) on a name now waits for every
holder of that name, whether shared or exclusive.  A shared claim
(HARNESS-SHARES) only waits out an exclusive holder, so any number of
them run together.

This also gives Runner::State its first unit test, and makes the two
bare $task->{conflicts} dereferences in _next() tolerate a task queued
without the key.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
We read the live window of each test out of the log and check which
windows were allowed to overlap.  Timing-dependent by nature: the "did
not overlap" half is solid, the "did overlap" half leans on the sleeps
in the fixtures, but concurrency.t already does that, so it's
acceptable, I guess.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
I think these were just misplaced?

Co-authored-by: Claude <noreply@anthropic.com>
@rjbs

rjbs commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

CI failures on older Perls are because the workflow uses cpm, which requires a more recent perl. I tested on v5.14 manually and it's fine. (I made an offer elsewhere to rewrite your test workflow, lmk.)

@exodist
exodist merged commit c6ce593 into Test-More:1.0 Aug 20, 2026
11 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants