feat(test): add --shard flag to split a test run across machines#35057
Draft
bartlomieju wants to merge 1 commit into
Draft
feat(test): add --shard flag to split a test run across machines#35057bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
`deno test --shard=<index>/<count>` runs only the test files belonging to the given 1-based shard, so a suite can be split across machines (as in Vitest, Jest, and Playwright). The discovered files are sorted for a stable order and split into <count> consecutive, balanced groups; the selection happens before any --shuffle so it is deterministic across machines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Large test suites are commonly split across CI machines, which Vitest, Jest,
and Playwright all support with a
--shardflag.deno testhad noequivalent, so the whole suite had to run on one machine.
This adds
deno test --shard=<index>/<count>(1-based index). The discoveredtest files are sorted for a stable order, then split into
<count>consecutive, balanced groups, and only the files for
<index>are run. Everyfile lands in exactly one shard and group sizes differ by at most one. The
selection happens before any
--shuffle, so a given shard runs the same fileson every machine regardless of the shuffle seed. Invalid values
(
index > count,indexorcountof 0, missing/) are rejected atflag-parse time.
Sharding is a pre-filter on the discovered file list, independent of how files
are executed, so it composes cleanly with filtering and any future test-runner
isolation/pooling changes.
This intentionally does not include cross-shard result merging (a combined
summary across shards); each shard reports its own subset and fails its own CI
job, and a merge step pairs naturally with the json reporter as a follow-up.