Skip to content

Commit

Permalink
groundwork around parallelizing mocha child runner
Browse files Browse the repository at this point in the history
  • Loading branch information
bttmly committed Aug 14, 2015
1 parent 88d5b42 commit 6106256
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 105 deletions.
96 changes: 0 additions & 96 deletions .jshintrc

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ events:
./bin/perturb -r ./examples/event-emitter

dogfood:
NODE_ENV=testing ./bin/perturb -r ./ -c 'make test'
NODE_ENV=testing ./bin/perturb --rootDir ./ --testCmd 'make test'

dogfood-parallel:
NODE_ENV=testing ./bin/perturb --rootDir ./ --testCmd 'make test' --runner mochaChild --parallel

dogfood-i:
NODE_ENV=testing ./bin/perturb -r ./ -i
Expand Down
3 changes: 3 additions & 0 deletions bin/_perturb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ program
.option("-i, --interception", "use interception strategy (no disk I/O)")
.option("-v, --verbose", "lots of logging")
.option("-k, --killRate", "minimum kill rate to exit with code 0")
.option("-p, --parallel", "run mutants in parallel (careful!)")
.option("-u, --runner <runner>")
.parse(process.argv);

if (program.rootDir && program.rootDir[0] !== "/") {
Expand All @@ -39,6 +41,7 @@ var userConfig = omitUndefined({
sourceGlob: program.sourceGlob,
testCmd: program.testCmd,
interception: program.interception,
runner: program.runner,
});

// this will become the default reporter
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ function makeSourceGroupHandler (config) {
var sourceCode = mutants[0].sourceCode;
var sourceFile = mutants[0].sourceFile;

var mapMethod = config.parallel ? async.map : async.mapSeries;

console.log(sourceFile, "starting....");
async.mapSeries(mutants, runMutant(config), function (err, processedMutants) {
mapMethod(mutants, runMutant(config), function (err, processedMutants) {
if (err) {
console.log("ERR!", err);
return done(err);
Expand Down
1 change: 1 addition & 0 deletions lib/run-mutant.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function createMultiMutantRunner (config) {
var last = finish(config, _done);
var tests = mutant.testFiles.slice();

console.log("RUNNER:", config.runner);
var runner = runners[config.runner || DEFAULT_RUNNER];
if (runner == null) {
throw new Error(ERRORS.InvalidReporter);
Expand Down
11 changes: 6 additions & 5 deletions lib/runners/mocha-child.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ function mochaChildProcessRunner (testFile, done) {
var exited;

var child = exec(cmd, opts, function (err, stdout, stderr) {
if (!exited && err) {
console.log("child error callback");
exited = true;
done(err.toString());
}
// if (!exited && err) {
// console.log("child error callback");
// exited = true;
// return done(err.toString());
// }

console.log("CHILD EXITED WITH 0?", child.exitCode === 0, err);
done();
});

Expand Down
2 changes: 0 additions & 2 deletions lib/types/mutator.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ function assertValidMutator (mutator) {
// console.log("Validation failed", msg);
throw new FmtError(ERRORS.InvalidMutator, msg);
}
// if (isMutatorValid(mutator)) return;
// throw new FmtError(ERRORS.InvalidMutator);
}

module.exports = assertValidMutator;

0 comments on commit 6106256

Please sign in to comment.