UNPKG

2.06 kBJavaScriptView Raw
1"use strict";
2/**
3 * This serves as the main function for starting a test run that has been
4 * requested by the launcher.
5 */
6Object.defineProperty(exports, "__esModule", { value: true });
7const configParser_1 = require("./configParser");
8const logger_1 = require("./logger");
9const runner_1 = require("./runner");
10let logger = new logger_1.Logger('runnerCli');
11process.on('message', (m) => {
12 switch (m.command) {
13 case 'run':
14 if (!m.capabilities) {
15 throw new Error('Run message missing capabilities');
16 }
17 // Merge in config file options.
18 let configParser = new configParser_1.ConfigParser();
19 if (m.configFile) {
20 configParser.addFileConfig(m.configFile);
21 }
22 if (m.additionalConfig) {
23 configParser.addConfig(m.additionalConfig);
24 }
25 let config = configParser.getConfig();
26 logger_1.Logger.set(config);
27 // Grab capabilities to run from launcher.
28 config.capabilities = m.capabilities;
29 // Get specs to be executed by this runner
30 config.specs = m.specs;
31 // Launch test run.
32 let runner = new runner_1.Runner(config);
33 // Pipe events back to the launcher.
34 runner.on('testPass', () => {
35 process.send({ event: 'testPass' });
36 });
37 runner.on('testFail', () => {
38 process.send({ event: 'testFail' });
39 });
40 runner.on('testsDone', (results) => {
41 process.send({ event: 'testsDone', results: results });
42 });
43 runner.run()
44 .then((exitCode) => {
45 process.exit(exitCode);
46 })
47 .catch((err) => {
48 logger.info(err.message);
49 process.exit(1);
50 });
51 break;
52 default:
53 throw new Error('command ' + m.command + ' is invalid');
54 }
55});
56//# sourceMappingURL=runnerCli.js.map
\No newline at end of file