Skip to content

Commit

Permalink
citgm-all: add skip option to lookup table
Browse files Browse the repository at this point in the history
  • Loading branch information
Myles Borins committed Nov 21, 2015
1 parent a9a1754 commit 805625c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
16 changes: 10 additions & 6 deletions bin/citgm-all
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ var options = {
};

var lookup = getLookup(options);
var modules = Object.getOwnPropertyNames(lookup);

if (!citgm.windows) {
var uidnumber = require('uid-number');
Expand All @@ -81,13 +80,18 @@ if (!citgm.windows) {
var exitCode = 0;
var failed = [];

function runCitgm (mod, next) {
citgm.Tester(mod, options)
function runCitgm (module, name, next) {
if (module.skip) {
next();
return;
}

citgm.Tester(name, options)
.on('start', function(name) {
log.info('starting', name);
}).on('fail', function(err) {
failed.push({
name: mod,
name: name,
err: err.message
});
log.error('failure', err.message);
Expand All @@ -108,12 +112,12 @@ function runCitgm (mod, next) {
}

function launch() {
async.eachSeries(modules, runCitgm, function done () {
async.forEachOfSeries(lookup, runCitgm, function done () {
if (exitCode) {
process.exitCode = exitCode;
log.error('done', 'citgm-all failed');
log.error('failed modules', failed);
process.exit();
process.exit(exitCode);
}
log.info('done', 'citgm-all passed.');
});
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/custom-lookup-skip.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"omg-i-pass": {
"replace": false
},
"omg-i-fail": {
"replace": false,
"skip": true
}
}
14 changes: 14 additions & 0 deletions test/fixtures/pretty-print.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"chalk": {
"replace": true,
"prefix": "v"
},
"colors": {
"replace": true,
"prefix": "v"
},
"yosay": {
"replace": true,
"prefix": "v"
}
}
11 changes: 11 additions & 0 deletions test/test-citgm-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,14 @@ test('citgm-all: fail', function (t) {
t.equals(code, 1, 'citgm-all should have failed');
});
});

test('citgm-all: skip', function (t) {
t.plan(1);
var proc = spawn(citgmAllPath, ['-l', 'test/fixtures/custom-lookup-skip.json']);
proc.on('error', function(err) {
t.error(err);
});
proc.on('close', function (code) {
t.equals(code, 0, 'it should run omg-i-pass and skip omg-i-fail');
});
});
5 changes: 3 additions & 2 deletions test/test-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ test('lookup[getLookupTable]: custom table', function (t) {
'omg-i-pass': {
replace: false
},
'rim-raf': {
replace: true
'rimraf': {
replace: true,
prefix: 'v'
}
}, 'we should receive the expected lookup table from the fixtures folder');
t.end();
Expand Down

0 comments on commit 805625c

Please sign in to comment.