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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(launcher): make launcher use child process messages instead …
…of messing with the env
- Loading branch information
Showing
2 changed files
with
124 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,39 @@ | ||
/** | ||
* This serves as the main function for starting a test run that has been | ||
* requested by the launcher. It assumes that the process environment has | ||
* been set with the following properties: | ||
* cliArgs - a stringified JSON object representing the CLI args passed | ||
* to this test run. | ||
* capability - a stringified JSON object representing the particular | ||
* capability to be used for this run. | ||
* numNumber - an identifier for this run, in case multiple runs of the same | ||
* capability were requested. | ||
* requested by the launcher. | ||
*/ | ||
|
||
var ConfigParser = require('./configParser'); | ||
var Runner = require('./runner'); | ||
|
||
var config, argv; | ||
|
||
// Merge in config file options. | ||
argv = JSON.parse(process.env.cliArgs); | ||
config = new ConfigParser(). | ||
addFileConfig(argv._[0]). | ||
addConfig(argv). | ||
getConfig(); | ||
process.on('message', function(m) { | ||
switch (m.command) { | ||
case 'run': | ||
if (!m.capability) { | ||
throw new Error('Run message missing capability'); | ||
} | ||
if (!m.cliArgs) { | ||
throw new Error('Run message missing cliArgs'); | ||
} | ||
// Merge in config file options. | ||
argv = m.cliArgs; | ||
config = new ConfigParser(). | ||
addFileConfig(argv._[0]). | ||
addConfig(argv). | ||
getConfig(); | ||
|
||
// Grab capability to run from launcher. | ||
config.capabilities = JSON.parse(process.env.capability); | ||
// Grab capability to run from launcher. | ||
config.capabilities = m.capability; | ||
|
||
// Launch test run. | ||
var runner = new Runner(config); | ||
runner.run().then(function(exitCode) { | ||
process.exit(exitCode); | ||
// Launch test run. | ||
var runner = new Runner(config); | ||
runner.run().then(function(exitCode) { | ||
process.exit(exitCode); | ||
}); | ||
break; | ||
default: | ||
throw new Error('command ' + m.command + ' is invalid'); | ||
} | ||
}); |