From 1c731aa9b3c9f5c122dbf3d0d554d95785657a48 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Fri, 5 May 2023 12:19:26 +0200 Subject: [PATCH] feat(scripts): run all benchmarks even if one fails (#18558) 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. --- scripts/bench.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/scripts/bench.ts b/scripts/bench.ts index 9f145b9892db..ecf34f6628cf 100644 --- a/scripts/bench.ts +++ b/scripts/bench.ts @@ -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)