Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit d66c2bd

Browse files
committed
chore(typescript): migrate runnerCli to TS
1 parent 47f54ad commit d66c2bd

File tree

3 files changed

+57
-66
lines changed

3 files changed

+57
-66
lines changed

lib/runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export class Runner extends EventEmitter {
3333
this.config_ = config;
3434
if (config.v8Debug) {
3535
// Call this private function instead of sending SIGUSR1 because Windows.
36-
process['_debugProcess'](process.pid);
36+
(<any>process)['_debugProcess'](process.pid);
3737
}
3838

3939
if (config.nodeDebug) {
40-
process['_debugProcess'](process.pid);
40+
(<any>process)['_debugProcess'](process.pid);
4141
let flow = webdriver.promise.controlFlow();
4242

4343
flow.execute(() => {

lib/runnerCli.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

lib/runnerCli.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* This serves as the main function for starting a test run that has been
3+
* requested by the launcher.
4+
*/
5+
6+
import {ConfigParser} from './configParser';
7+
import {Logger} from './logger2';
8+
import {Runner} from './runner';
9+
10+
let logger = new Logger('runnerCli');
11+
12+
process.on('message', (m: any) => {
13+
switch (m.command) {
14+
case 'run':
15+
if (!m.capabilities) {
16+
throw new Error('Run message missing capabilities');
17+
}
18+
// Merge in config file options.
19+
let configParser = new ConfigParser();
20+
if (m.configFile) {
21+
configParser.addFileConfig(m.configFile);
22+
}
23+
if (m.additionalConfig) {
24+
configParser.addConfig(m.additionalConfig);
25+
}
26+
let config = configParser.getConfig();
27+
Logger.set(config);
28+
29+
// Grab capabilities to run from launcher.
30+
config.capabilities = m.capabilities;
31+
32+
// Get specs to be executed by this runner
33+
config.specs = m.specs;
34+
35+
// Launch test run.
36+
let runner = new Runner(config);
37+
38+
// Pipe events back to the launcher.
39+
runner.on('testPass', () => { process.send({event: 'testPass'}); });
40+
runner.on('testFail', () => { process.send({event: 'testFail'}); });
41+
runner.on('testsDone', (results: any) => {
42+
process.send({event: 'testsDone', results: results});
43+
});
44+
45+
runner.run()
46+
.then((exitCode: number) => { process.exit(exitCode); })
47+
.catch((err: Error) => {
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+
});

0 commit comments

Comments
 (0)