Created
October 14, 2016 02:44
-
-
Save davidpaulhunt/03d36303062ba6b7418b2ec14f2a9db6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* Initially, test runs were handled via a single executable | |
* causing many large objects and references from within setup | |
* code, and perhaps vows, to hang around despite garbage collection. | |
*/ | |
(function runFile(i) { | |
if (i > filenames.length) { | |
return exit(); | |
} | |
const filename = filenames[i]; | |
let file; | |
// ...try/catch load file | |
file.vows(new Tools(file.options || {})).run((results) => { | |
// ...process results, aggregate, store filename for later | |
return runFile(i + 1); | |
}); | |
})(0); | |
/* | |
* In order to insulate itself from bloat, the main process | |
* creates a fork responsible for running the current test file | |
* via its own child process using ChildProcess.execFile, then | |
* the forked process reports back to the main process via Redis. | |
*/ | |
(function orchestrate() { | |
if (_.isEmpty(filenames)) { | |
return exit(); | |
} | |
const filename = filenames.shift(); | |
let file; | |
// ...try/catch load file, check against requested suites or filenames if applicable | |
const child = childProcess.fork(CHILD_PATH, [filename]); | |
// ...store child's pid to ensure it's killed when the parent process exits | |
child.on('close', () => { | |
// ...store filename for later | |
fetchResultsFromRedis(filename, orchestrate); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment