Skip to content

Commit

Permalink
feat(scripts): run all benchmarks even if one fails (#18558)
Browse files Browse the repository at this point in the history
Run all bechmarks and only print failures rather than exiting as soon
as one benchmark fails, and only then throw an error if there were
failures. This makes the benchmark runner behave more similarly to a
test runner, and it will prevent CodSpeed from marking other
benchmarks as "dropped" when one of them crashes.
  • Loading branch information
aqrln committed May 5, 2023
1 parent 57c3540 commit 1c731aa
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions scripts/bench.ts
Expand Up @@ -19,12 +19,25 @@ async function main() {
}

async function run(benchmarks: string[]) {
let failedCount = 0

for (const location of benchmarks) {
await execa.command(`node -r esbuild-register ${location}`, {
stdio: 'inherit',
})
try {
await execa.command(`node -r esbuild-register ${location}`, {
stdio: 'inherit',
})
} catch (e) {
console.error(e)
failedCount++
}
}

if (failedCount > 0) {
const pluralMarker = failedCount === 1 ? '' : 's'
throw new Error(`${failedCount} benchmark${pluralMarker} failed`)
}
}

main().catch((e) => {
console.error(e)
process.exit(1)
Expand Down

0 comments on commit 1c731aa

Please sign in to comment.