remote_runner: `await` each browser test
parent
1f3a831cc3
commit
014e19cf7d
|
@ -1,5 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// As of v14, Node.js does not exit when there is an unhandled Promise rejection. Convert an
|
||||||
|
// unhandled rejection into an uncaught exception, which does cause Node.js to exit.
|
||||||
|
process.on('unhandledRejection', (err) => { throw err; });
|
||||||
|
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const wd = require('wd');
|
const wd = require('wd');
|
||||||
|
|
||||||
|
@ -12,18 +16,6 @@ const config = {
|
||||||
|
|
||||||
const isAdminRunner = process.argv[2] === 'admin';
|
const isAdminRunner = process.argv[2] === 'admin';
|
||||||
|
|
||||||
let allTestsPassed = true;
|
|
||||||
// overwrite the default exit code
|
|
||||||
// in case not all worker can be run (due to saucelabs limits),
|
|
||||||
// `queue.drain` below will not be called
|
|
||||||
// and the script would silently exit with error code 0
|
|
||||||
process.exitCode = 2;
|
|
||||||
process.on('exit', (code) => {
|
|
||||||
if (code === 2) {
|
|
||||||
console.log('\x1B[31mFAILED\x1B[39m Not all saucelabs runner have been started.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const sauceTestWorker = async.queue((testSettings, callback) => {
|
const sauceTestWorker = async.queue((testSettings, callback) => {
|
||||||
const browser = wd.promiseChainRemote(
|
const browser = wd.promiseChainRemote(
|
||||||
config.host, config.port, config.username, config.accessKey);
|
config.host, config.port, config.username, config.accessKey);
|
||||||
|
@ -48,9 +40,7 @@ const sauceTestWorker = async.queue((testSettings, callback) => {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
|
||||||
browser.quit(() => {
|
browser.quit(() => {
|
||||||
if (!success) {
|
if (!success) process.exitCode = 1;
|
||||||
allTestsPassed = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// if stopSauce is called via timeout
|
// if stopSauce is called via timeout
|
||||||
// (in contrast to via getStatusInterval) than the log of up to the last
|
// (in contrast to via getStatusInterval) than the log of up to the last
|
||||||
|
@ -128,7 +118,7 @@ const sauceTestWorker = async.queue((testSettings, callback) => {
|
||||||
});
|
});
|
||||||
}, 6); // run 6 tests in parrallel
|
}, 6); // run 6 tests in parrallel
|
||||||
|
|
||||||
[
|
Promise.all([
|
||||||
{
|
{
|
||||||
platform: 'OS X 10.15',
|
platform: 'OS X 10.15',
|
||||||
browserName: 'safari',
|
browserName: 'safari',
|
||||||
|
@ -157,8 +147,4 @@ const sauceTestWorker = async.queue((testSettings, callback) => {
|
||||||
version: '78.0',
|
version: '78.0',
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
].forEach((task) => sauceTestWorker.push(task));
|
].map(async (task) => await sauceTestWorker.push(task)));
|
||||||
|
|
||||||
sauceTestWorker.drain(() => {
|
|
||||||
process.exit(allTestsPassed ? 0 : 1);
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in New Issue