This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
runnerCli.ts
59 lines (51 loc) · 1.54 KB
/
runnerCli.ts
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
56
57
58
59
/**
* This serves as the main function for starting a test run that has been
* requested by the launcher.
*/
import {ConfigParser} from './configParser';
import {Logger} from './logger';
import {Runner} from './runner';
let logger = new Logger('runnerCli');
process.on('message', (m: any) => {
if (m.command === 'run') {
if (!m.capabilities) {
throw new Error('Run message missing capabilities');
}
// Merge in config file options.
let configParser = new ConfigParser();
if (m.configFile) {
configParser.addFileConfig(m.configFile);
}
if (m.additionalConfig) {
configParser.addConfig(m.additionalConfig);
}
let config = configParser.getConfig();
Logger.set(config);
// Grab capabilities to run from launcher.
config.capabilities = m.capabilities;
// Get specs to be executed by this runner
config.specs = m.specs;
// Launch test run.
let runner = new Runner(config);
// Pipe events back to the launcher.
runner.on('testPass', () => {
process.send({event: 'testPass'});
});
runner.on('testFail', () => {
process.send({event: 'testFail'});
});
runner.on('testsDone', (results: any) => {
process.send({event: 'testsDone', results: results});
});
runner.run()
.then((exitCode: number) => {
process.exit(exitCode);
})
.catch((err: Error) => {
logger.info(err.message);
process.exit(1);
});
} else {
throw new Error('command ' + m.command + ' is invalid');
}
});