Skip to content

Commit

Permalink
feat: add --concurrency option
Browse files Browse the repository at this point in the history
  • Loading branch information
ChALkeR committed Sep 5, 2024
1 parent 1f906f4 commit 4470bf1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const ENGINES = new Map(

function parseOptions() {
const options = {
concurrency: undefined, // undefined means unset (can read from config), 0 means auto
jest: false,
typescript: false,
flow: false,
Expand Down Expand Up @@ -154,6 +155,12 @@ function parseOptions() {
case '--idea-compat':
options.ideaCompat = true
break
case '--concurrency':
const concurrency = args.shift()
options.concurrency = Number(concurrency)
assert.equal(concurrency, `${options.concurrency}`)
assert(Number.isInteger(options.concurrency) && options.concurrency >= 0)
break
case '--test-name-pattern':
case '--testNamePattern':
options.testNamePattern.push(args.shift())
Expand Down Expand Up @@ -513,7 +520,7 @@ if (options.pure) {
}
}

const queue = new Queue(availableParallelism() - 1)
const queue = new Queue(options.concurrency || availableParallelism() - 1)
const runConcurrent = async (file) => {
await queue.claim()
try {
Expand Down Expand Up @@ -549,6 +556,7 @@ if (options.pure) {
setEnv('EXODUS_TEST_CONTEXT', options.engine)
assert(files.length > 0) // otherwise we can run recursively
assert(!options.binaryArgs)
if (options.concurrency) args.push('--test-concurrency', options.concurrency)
const { code } = await launch(options.binary, [...args, ...files])
process.exitCode = code
}

0 comments on commit 4470bf1

Please sign in to comment.