From e0832c5723880c23851c05cbef229634f4af97a1 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Fri, 5 Jan 2024 16:54:34 +0100 Subject: [PATCH] If a browsertime marks a test as a failure, exit with error code (#4047) --- bin/sitespeed.js | 8 ++++++++ lib/plugins/browsertime/index.js | 2 ++ 2 files changed, 10 insertions(+) diff --git a/bin/sitespeed.js b/bin/sitespeed.js index bcbd7fcec..6570b2ceb 100755 --- a/bin/sitespeed.js +++ b/bin/sitespeed.js @@ -148,6 +148,14 @@ async function start() { execSync('xdg-open ' + result.localPath + '/index.html'); } + // If one of the URLs is marked as a failure in Browsertime + // then set the exit code + for (let bt of result.browsertime) { + if (bt.markedAsFailure === 1) { + process.exitCode = 1; + } + } + if ( parsed.options.budget && Object.keys(result.budgetResult.failing).length > 0 diff --git a/lib/plugins/browsertime/index.js b/lib/plugins/browsertime/index.js index b761af7bc..ab9ae4244 100644 --- a/lib/plugins/browsertime/index.js +++ b/lib/plugins/browsertime/index.js @@ -364,6 +364,8 @@ export default class BrowsertimePlugin extends SitespeedioPlugin { run.extras = result[resultIndex].extras[runIndex]; } + run.markedAsFailure = result[resultIndex].markedAsFailure; + if ( result[resultIndex].cdp && result[resultIndex].cdp.performance