diff --git a/lib/runner.ts b/lib/runner.ts index e2cb053a9..3e045bc49 100644 --- a/lib/runner.ts +++ b/lib/runner.ts @@ -33,11 +33,11 @@ export class Runner extends EventEmitter { this.config_ = config; if (config.v8Debug) { // Call this private function instead of sending SIGUSR1 because Windows. - process['_debugProcess'](process.pid); + (process)['_debugProcess'](process.pid); } if (config.nodeDebug) { - process['_debugProcess'](process.pid); + (process)['_debugProcess'](process.pid); let flow = webdriver.promise.controlFlow(); flow.execute(() => { diff --git a/lib/runnerCli.js b/lib/runnerCli.js deleted file mode 100644 index 32a1115ca..000000000 --- a/lib/runnerCli.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * This serves as the main function for starting a test run that has been - * requested by the launcher. - */ - -var ConfigParser = require('./configParser').ConfigParser; -var Runner = require('./runner').Runner; -var log = require('./logger'); - -process.on('message', function(m) { - switch (m.command) { - case 'run': - if (!m.capabilities) { - throw new Error('Run message missing capabilities'); - } - // Merge in config file options. - var configParser = new ConfigParser(); - if (m.configFile) { - configParser.addFileConfig(m.configFile); - } - if (m.additionalConfig) { - configParser.addConfig(m.additionalConfig); - } - var config = configParser.getConfig(); - log.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. - var runner = new Runner(config); - - // Pipe events back to the launcher. - runner.on('testPass', function() { - process.send({ - event: 'testPass' - }); - }); - runner.on('testFail', function() { - process.send({ - event: 'testFail' - }); - }); - runner.on('testsDone', function(results) { - process.send({ - event: 'testsDone', - results: results - }); - }); - - runner.run().then(function(exitCode) { - process.exit(exitCode); - }).catch (function(err) { - log.puts(err.message); - process.exit(1); - }); - break; - default: - throw new Error('command ' + m.command + ' is invalid'); - } -}); diff --git a/lib/runnerCli.ts b/lib/runnerCli.ts new file mode 100644 index 000000000..7f1dc3aec --- /dev/null +++ b/lib/runnerCli.ts @@ -0,0 +1,55 @@ +/** + * 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 './logger2'; +import {Runner} from './runner'; + +let logger = new Logger('runnerCli'); + +process.on('message', (m: any) => { + switch (m.command) { + case '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); + }); + break; + default: + throw new Error('command ' + m.command + ' is invalid'); + } +});