Skip to content

test: prove pLimit limits page concurrency - #289

Merged
l2ysho merged 1 commit into
mainfrom
test/plimit-concurrency-and-break-threshold
Aug 29, 2026
Merged

test: prove pLimit limits page concurrency#289
l2ysho merged 1 commit into
mainfrom
test/plimit-concurrency-and-break-threshold

Conversation

@l2ysho

@l2ysho l2ysho commented Aug 29, 2026

Copy link
Copy Markdown
Owner

First mutant-killing PR from the report at l2ysho.github.io/afpp.

The gap

src/core.ts:20 reads if (active < concurrency && queue.length > 0). Stryker replaced the condition with true and every test still passed. Nothing in the suite proved that page processing is actually limited.

The existing concurrency tests only check that a run with concurrency: 'auto' finishes, and that concurrency: 0 throws. Neither observes how many pages run at once.

The test

Counts callbacks in flight and asserts the peak equals the configured concurrency:

const data = await parsePdf(input, { concurrency }, async (content) => {
  active++;
  peak = Math.max(peak, active);
  await delay(50);
  active--;
  return content;
});
assert.equal(peak, concurrency);

example.pdf has 9 pages. With concurrency: 2 the limit lets exactly two through. With the mutant applied all nine start at once, the peak is 9, and the test fails — verified by applying the mutant by hand.

The peak is deterministic, not timing-dependent: pLimit starts tasks as they are pushed, so the third push onward is queued. The 50 ms hold only keeps the two in-flight callbacks overlapping long enough to be observed. Ran the file five times, stable.

Result

Before After
All files 61.13 % 63.77 %
src/core.ts 60.85 % 64.55 %
Killed 133 140
Survived 100 93

Every mutant in the pLimit block is now killed, timed out, or errors out. None survive — previously the true replacement, active--, and active <= concurrency all got through.

Also

thresholds.break moves from null to 60. main now has a trustworthy full run, so the score cannot silently regress below it. Raise it as more mutants die.

Next

src/getPdfMetadata.ts is still at 38.64 % with 27 survived, 11 of them string mutants around the empty-string guard in toOptionalString. One fixture with empty metadata fields should kill most of that file.

🤖 Generated with Claude Code

Mutation testing showed `active < concurrency` could be replaced by
`true` with every test still passing. Nothing anywhere proved that page
processing is actually limited; the existing concurrency tests only check
that a run finishes and that invalid values throw.

The new test counts callbacks in flight and asserts the peak equals the
configured concurrency. With the mutant applied all nine pages start at
once and the peak is 9, so the test fails.

Every mutant in the pLimit block is now killed, timed out or errors out.
None survive. The score goes from 61.13 to 63.77, and core.ts from 60.85
to 64.55.

`thresholds.break` moves from null to 60 so the score cannot regress
below the baseline that main now has.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@l2ysho
l2ysho merged commit 478bbbc into main Aug 29, 2026
8 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.

1 participant