-
-
Notifications
You must be signed in to change notification settings - Fork 737
/
Copy pathrun-workers.js
55 lines (47 loc) · 1.52 KB
/
run-workers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// For Node version >=10.5.0, have to use experimental flag
const { tryOrDefault } = require('../utils');
const output = require('../output');
const event = require('../event');
const Workers = require('../workers');
module.exports = async function (workerCount, selectedRuns, options) {
process.env.profile = options.profile;
const { config: testConfig, override = '' } = options;
const overrideConfigs = tryOrDefault(() => JSON.parse(override), {});
const by = options.suites ? 'suite' : 'test';
delete options.parent;
const config = {
by,
testConfig,
options,
selectedRuns,
};
const numberOfWorkers = parseInt(workerCount, 10);
output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`);
output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`);
output.print();
const workers = new Workers(numberOfWorkers, config);
workers.overrideConfig(overrideConfigs);
workers.on(event.test.failed, (failedTest) => {
output.test.failed(failedTest);
});
workers.on(event.test.passed, (successTest) => {
output.test.passed(successTest);
});
workers.on(event.all.result, () => {
workers.printResults();
});
try {
if (options.verbose) {
global.debugMode = true;
const { getMachineInfo } = require('./info');
await getMachineInfo();
}
await workers.bootstrapAll();
await workers.run();
} catch (err) {
output.error(err);
process.exit(1);
} finally {
await workers.teardownAll();
}
};