Skip to content

Commit

Permalink
file shuffling
Browse files Browse the repository at this point in the history
  • Loading branch information
bttmly committed Jul 28, 2016
1 parent ece951f commit c8d7c3e
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 611 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ example-events:
rm -rf ./.perturb
rm -rf ./built
./node_modules/.bin/tsc
node ./run.js events
node ./script/run.js events

dogfood:
rm -rf ./.perturb
rm -rf ./built
./node_modules/.bin/tsc
node ./run.js dogfood $(RUNNER)
node ./script/run.js dogfood $(RUNNER)

build:
./node_modules/.bin/tsc --strictNullChecks
Expand Down
33 changes: 0 additions & 33 deletions script/compare-runners.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,9 @@
var silence = (function () {

var methods = {
log: console.log,
info: console.info,
warn: console.warn,
error: console.error,
dir: console.dir,
time: console.time,
timeEnd: console.timeEnd,
trace: console.trace,
assert: console.assert,
}

function noop () {}

return function silence () {

Object.keys(methods).forEach(function (k) {
console[k] = noop;
});

return function restore () {
Object.keys(methods).forEach(function (k) {
console[k] = methods[k];
});
}
};

})();


var assert = require("assert");

var generateConfig = require("../lib/config");
var runners = require("../lib/runners");
var perturb = require("../lib");


function compare (runnerA, runnerB) {
var optionsA = generateConfig({runner: runnerA});
var optionsB = generateConfig({runner: runnerB});
Expand Down
541 changes: 0 additions & 541 deletions script/flags.json

This file was deleted.

20 changes: 0 additions & 20 deletions script/generate-flags.js

This file was deleted.

12 changes: 5 additions & 7 deletions run.js → script/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ const path = require("path");
function run (perturb, which, runner) {
let config;

console.log("WHICH", which);

switch (which.trim()) {
case "dogfood":
config = {
projectRoot: path.join(__dirname, ".."),
projectRoot: path.join(__dirname, "../"),
sourceDir: "built",
runner: runner || "mocha",
reporter: "name",
Expand All @@ -18,15 +16,15 @@ function run (perturb, which, runner) {

case "events":
config = {
testCmd: `node ${path.join(__dirname, "./examples/event-emitter/test.js")}`,
testCmd: `node ${path.join(__dirname, "../examples/event-emitter/test.js")}`,
matcher: {
type: "comparative",
makeMatcher: () => () => true,
},
projectRoot: path.join(__dirname, "./examples/event-emitter"),
projectRoot: path.join(__dirname, "../examples/event-emitter"),
sourceDir: "lib",
testDir: "test",
runner: "node",
runner: "require",
}
break;

Expand All @@ -46,7 +44,7 @@ function run (perturb, which, runner) {
}

if (!module.parent) {
run(require("./built"), process.argv[2], process.argv[3]);
run(require("../built"), process.argv[2], process.argv[3]);
}

module.exports = run;
2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ function perturb (_cfg: PerturbConfig) {
throw new Error("No matched files!");
}

console.log("MATCHES:", matches);

start = Date.now();

const mutants = R.chain(makeMutants, tested);
Expand Down
2 changes: 1 addition & 1 deletion src/runners/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const plugins = new Map<string, RunnerPlugin>()
;[
require("./mocha"),
require("./mocha-fork"),
require("./node"),
require("./require"),
].forEach(function (runner) {
plugins.set(runner.name, runner);
});
Expand Down
7 changes: 2 additions & 5 deletions src/runners/node.ts → src/runners/require.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ import {
} from "../types";

export = <RunnerPlugin>{
name: "node",
name: "require",
setup (m: Mutant) {
runnerUtils.clearRequireCache();
runnerUtils.writeMutatedCode(m);
return Promise.resolve();
},
run (m: Mutant) {
try {
m.testFiles.map(f => {
console.log("about to require", f);
require(f)
});
m.testFiles.forEach(f => require(f));
} catch (error) {
return Promise.resolve(Object.assign({}, m, { error }));
}
Expand Down

0 comments on commit c8d7c3e

Please sign in to comment.