Skip to content

Commit ecebd34

Browse files
authored
🏗 Follow up changes to integration tests on sauce labs (ampproject#24623)
1 parent 48a2812 commit ecebd34

File tree

3 files changed

+46
-28
lines changed

3 files changed

+46
-28
lines changed

build-system/pr-check/remote-tests.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@ const {
2929
stopTimer,
3030
startSauceConnect,
3131
stopSauceConnect,
32-
timedExec,
3332
timedExecOrDie: timedExecOrDieBase,
3433
} = require('./utils');
3534
const {determineBuildTargets} = require('./build-targets');
3635
const {isTravisPullRequestBuild} = require('../travis');
3736

3837
const FILENAME = 'remote-tests.js';
3938
const FILELOGPREFIX = colors.bold(colors.yellow(`${FILENAME}:`));
40-
const timedExecOrDie = (cmd, unusedFileName) =>
41-
timedExecOrDieBase(cmd, FILENAME);
39+
const timedExecOrDie = cmd => timedExecOrDieBase(cmd, FILENAME);
4240

4341
async function main() {
4442
const startTime = startTimer(FILENAME, FILENAME);
@@ -49,7 +47,10 @@ async function main() {
4947

5048
await startSauceConnect(FILENAME);
5149
timedExecOrDie('gulp unit --nobuild --saucelabs');
52-
timedExecOrDie('gulp integration --nobuild --compiled --saucelabs');
50+
timedExecOrDie(
51+
'gulp integration --nobuild --compiled --saucelabs --stable'
52+
);
53+
timedExecOrDie('gulp integration --nobuild --compiled --saucelabs --beta');
5354

5455
stopSauceConnect(FILENAME);
5556
} else {
@@ -86,7 +87,9 @@ async function main() {
8687
timedExecOrDie(
8788
'gulp integration --nobuild --compiled --saucelabs --stable'
8889
);
89-
timedExec('gulp integration --nobuild --compiled --saucelabs --beta');
90+
timedExecOrDie(
91+
'gulp integration --nobuild --compiled --saucelabs --beta'
92+
);
9093
}
9194
stopSauceConnect(FILENAME);
9295
}

build-system/tasks/report-test-status.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ const IS_GULP_E2E = argv._[0] === 'e2e';
3030

3131
const IS_LOCAL_CHANGES = !!argv.local_changes;
3232
const IS_SAUCELABS = !!argv.saucelabs;
33+
const IS_SAUCELABS_STABLE = !!argv.saucelabs && !!argv.stable;
34+
const IS_SAUCELABS_BETA = !!argv.saucelabs && !!argv.beta;
3335
const IS_SINGLE_PASS = !!argv.single_pass;
3436

3537
const TEST_TYPE_SUBTYPES = new Map([
36-
['integration', ['local', 'single-pass', 'saucelabs']],
38+
[
39+
'integration',
40+
['local', 'single-pass', 'saucelabs-beta', 'saucelabs-stable'],
41+
],
3742
['unit', ['local', 'local-changes', 'saucelabs']],
3843
['e2e', ['local']],
3944
]);
@@ -61,7 +66,11 @@ function inferTestType() {
6166
return `${type}/local-changes`;
6267
}
6368

64-
if (IS_SAUCELABS) {
69+
if (IS_SAUCELABS_BETA) {
70+
return `${type}/saucelabs-beta`;
71+
} else if (IS_SAUCELABS_STABLE) {
72+
return `${type}/saucelabs-stable`;
73+
} else if (IS_SAUCELABS) {
6574
return `${type}/saucelabs`;
6675
}
6776

build-system/tasks/runtime-test/helpers.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const fs = require('fs');
2020
const log = require('fancy-log');
2121
const opn = require('opn');
2222
const path = require('path');
23-
2423
const {
2524
reportTestErrored,
2625
reportTestFinished,
@@ -195,18 +194,20 @@ function karmaBrowserStart_(browser) {
195194
* @param {Object} browser
196195
* @private
197196
*/
198-
function karmaBrowserComplete_(browser) {
197+
async function karmaBrowserComplete_(browser) {
199198
const result = browser.lastResult;
200199
result.total = result.success + result.failed + result.skipped;
201-
// Prevent cases where Karma detects zero tests and still passes. #16851.
200+
// Set test status to "error" if browser_complete shows zero tests (#16851).
201+
// Sometimes, Sauce labs can follow this up with another successful status, in
202+
// which case the error status will be replaced by a pass / fail status.
202203
if (result.total == 0) {
203-
log(red('ERROR: Zero tests detected by Karma.'));
204-
log(red(JSON.stringify(result)));
205-
reportTestErrored().finally(() => {
206-
if (!argv.watch) {
207-
process.exit(1);
208-
}
209-
});
204+
log(
205+
yellow('WARNING:'),
206+
'Received a status with zero tests:',
207+
cyan(JSON.stringify(result))
208+
);
209+
await reportTestErrored();
210+
return;
210211
}
211212
// Print a summary for each browser as soon as tests complete.
212213
let message =
@@ -265,7 +266,7 @@ async function runTestInSauceLabs(config) {
265266

266267
if (argv.beta) {
267268
config.browsers = browsers.beta;
268-
const betaExitCode = await createKarmaServer(config, () => {});
269+
const betaExitCode = await createKarmaServer(config, reportTestRunComplete);
269270
if (betaExitCode != 0) {
270271
log(
271272
yellow('Some tests have failed on'),
@@ -300,14 +301,22 @@ async function runTestInSauceLabs(config) {
300301
*/
301302
async function runTestInBatches_(config, browsers) {
302303
let errored = false;
303-
let totalStableSuccess = 0;
304-
let totalStableFailed = 0;
304+
let totalSuccess = 0;
305+
let totalFailed = 0;
305306
const partialTestRunCompleteFn = async (browsers, results) => {
306307
if (results.error) {
307308
errored = true;
308309
} else {
309-
totalStableSuccess += results.success;
310-
totalStableFailed += results.failed;
310+
totalSuccess += results.success;
311+
totalFailed += results.failed;
312+
}
313+
};
314+
315+
const reportResults = async () => {
316+
if (errored) {
317+
await reportTestErrored();
318+
} else {
319+
await reportTestFinished(totalSuccess, totalFailed);
311320
}
312321
};
313322

@@ -318,12 +327,8 @@ async function runTestInBatches_(config, browsers) {
318327
config,
319328
partialTestRunCompleteFn
320329
);
321-
if (errored) {
322-
await reportTestErrored();
323-
} else {
324-
await reportTestFinished(totalStableSuccess, totalStableFailed);
325-
}
326330
if (allBatchesExitCodes || errored) {
331+
await reportResults();
327332
log(
328333
yellow('Some tests have failed on'),
329334
cyan('stable'),
@@ -340,7 +345,7 @@ async function runTestInBatches_(config, browsers) {
340345
'beta',
341346
browsers.beta,
342347
config,
343-
/* runCompleteFn */ () => {}
348+
partialTestRunCompleteFn
344349
);
345350
if (allBatchesExitCodes) {
346351
log(
@@ -356,6 +361,7 @@ async function runTestInBatches_(config, browsers) {
356361
}
357362
}
358363

364+
await reportResults();
359365
return 0;
360366
}
361367

0 commit comments

Comments
 (0)