-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mocha style _perturb spawner; mutant API changes
- Loading branch information
Showing
8 changed files
with
154 additions
and
77 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,19 +1,19 @@ | ||
test: | ||
NODE_ENV='testing' ./node_modules/.bin/_mocha ./test/**/*.js | ||
./node_modules/.bin/_mocha ./test/**/*.js | ||
|
||
test-example: | ||
NODE_ENV='testing' ./node_modules/.bin/_mocha ./example/test/**/*-test.js | ||
./node_modules/.bin/_mocha ./example/test/**/*-test.js | ||
|
||
example: | ||
NODE_ENV='testing' ./bin/perturb -r ./example | ||
./bin/perturb -r ./example | ||
|
||
example-i: | ||
NODE_ENV='testing' ./bin/perturb -r ./example -i | ||
./bin/perturb -r ./example -i | ||
|
||
dogfood: | ||
NODE_ENV='testing' ./bin/perturb -r ./ | ||
./bin/perturb -r ./ | ||
|
||
dogfood-i: | ||
NODE_ENV='testing' ./bin/perturb -r ./ -i | ||
./bin/perturb -r ./ -i | ||
|
||
.PHONY: test example |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env node | ||
|
||
"use strict"; | ||
|
||
console.log(process.argv); | ||
|
||
var program = require("commander"); | ||
|
||
var path = require("path"); | ||
|
||
var perturb = require("../"); | ||
var util = require("../lib/util"); | ||
var pkg = require("../package.json"); | ||
|
||
function assignNoUndefined (target, source) { | ||
Object.keys(source).forEach(function (key) { | ||
if (source[key] === undefined) return; | ||
target[key] = source[key]; | ||
}); | ||
return target; | ||
} | ||
|
||
program | ||
.version(pkg.version) | ||
.option("-r, --rootDir <rootDir>", "root directory of the project") | ||
.option("-t, --testDir <testDir>", "test directory relative to root directory") | ||
.option("-s, --sourceDir <sourceDir>", "source directory relative to root directory") | ||
.option("-x, --testGlob <testGlob>", "glob for selecting files in test directory") | ||
.option("-y, --sourceGlob <sourceGlob>", "glob for selecting files in source directory") | ||
.option("-i, --interception", "use interception strategy (no disk I/O)") | ||
.parse(process.argv); | ||
|
||
if (program.rootDir && program.rootDir[0] !== "/") { | ||
program.rootDir = path.join(process.cwd(), program.rootDir); | ||
} | ||
|
||
var config = assignNoUndefined({}, { | ||
rootDir: program.rootDir, | ||
testDir: program.testDir, | ||
sourceDir: program.sourceDir, | ||
testGlob: program.testGlob, | ||
sourceGlob: program.sourceGlob, | ||
interception: program.interception | ||
}); | ||
|
||
// this will become the default reporter | ||
function reporter (err, data) { | ||
if (err) throw err; | ||
var mutants = data.matches[0].mutations; | ||
console.log(data.meta); | ||
} | ||
|
||
perturb(config, reporter); |
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,50 +1,61 @@ | ||
#!/usr/bin/env node | ||
#!/usr/bin/env node | ||
|
||
"use strict"; | ||
// shamelessly appropriated from mocha | ||
|
||
var program = require("commander"); | ||
"use strict"; | ||
|
||
var path = require("path"); | ||
|
||
var perturb = require("../"); | ||
var util = require("../lib/util"); | ||
var pkg = require("../package.json"); | ||
var spawn = require("child_process").spawn; | ||
var perturb = path.join(__dirname, "_perturb"); | ||
var args = [perturb]; | ||
|
||
var bin = process.argv[0]; | ||
|
||
process.argv.slice(2).forEach(function (arg) { | ||
var flag = arg.split("=")[0]; | ||
|
||
switch (flag) { | ||
|
||
case "--iojs": | ||
return bin = "iojs"; | ||
|
||
case "--harmony": | ||
case "--harmony-proxies": | ||
case "--harmony-collections": | ||
case "--harmony-generators": | ||
case "--harmony_shipping": | ||
case "--harmony_arrow_functions": | ||
case "--harmony_proxies": | ||
return args.unshift(arg); | ||
|
||
default: | ||
return args.push(arg); | ||
|
||
function assignNoUndefined (target, source) { | ||
Object.keys(source).forEach(function (key) { | ||
if (source[key] === undefined) return; | ||
target[key] = source[key]; | ||
} | ||
|
||
}); | ||
|
||
console.log([bin].concat(args).join(" ")); | ||
|
||
var proc = spawn(bin, args, {stdio: 'inherit'}); | ||
|
||
|
||
proc.on('exit', function (code, signal) { | ||
process.on('exit', function(){ | ||
if (signal) { | ||
process.kill(process.pid, signal); | ||
} else { | ||
process.exit(code); | ||
} | ||
}); | ||
return target; | ||
} | ||
|
||
program | ||
.version(pkg.version) | ||
.option("-r, --rootDir <rootDir>", "root directory of the project") | ||
.option("-t, --testDir <testDir>", "test directory relative to root directory") | ||
.option("-s, --sourceDir <sourceDir>", "source directory relative to root directory") | ||
.option("-x, --testGlob <testGlob>", "glob for selecting files in test directory") | ||
.option("-y, --sourceGlob <sourceGlob>", "glob for selecting files in source directory") | ||
.option("-i, --interception", "use interception strategy (no disk I/O)") | ||
.parse(process.argv); | ||
|
||
if (program.rootDir && program.rootDir[0] !== "/") { | ||
program.rootDir = path.join(process.cwd(), program.rootDir); | ||
} | ||
|
||
var config = assignNoUndefined({}, { | ||
rootDir: program.rootDir, | ||
testDir: program.testDir, | ||
sourceDir: program.sourceDir, | ||
testGlob: program.testGlob, | ||
sourceGlob: program.sourceGlob, | ||
interception: program.interception | ||
}); | ||
|
||
// this will become the default reporter | ||
function reporter (err, data) { | ||
if (err) throw err; | ||
console.log(data.meta); | ||
} | ||
proc.on('error', console.log); | ||
|
||
perturb(config, reporter); | ||
// terminate children. | ||
process.on('SIGINT', function () { | ||
proc.kill('SIGINT'); // calls runner.abort() | ||
proc.kill('SIGTERM'); // if that didn't work, we're probably in an infinite loop, so make it die. | ||
process.kill(process.pid, 'SIGINT'); | ||
}); |
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
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