Skip to content

Commit

Permalink
test: fix empty subtest in TAP output
Browse files Browse the repository at this point in the history
When run in the master process scenario, the subtest had 0 assertions in
it. The resulting TAP output confuses tap4j causing all sorts of fun.

Only load tap in the child process so that the only TAP that is seen by
the runner is coming from the child process and not double-interpretted
by tap being loaded into the parent process.

This entire test is way more complicated than it should be. I'm not sure
what it is supposed to be testing, but it sure doesn't fit with how
node-tap was meant to work.
  • Loading branch information
rmg committed Jul 26, 2016
1 parent 277772e commit 95f48e5
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions test/test-load-msg-forking.js
Expand Up @@ -7,33 +7,32 @@ var async = require('async');
var f = require('util').format;
var helper = require('../lib/helper');
var loadMsgHelper = require('./load-msg-helper');
var test = require('tap').test;

var wellKnownLangs = loadMsgHelper.wellKnownLangs;
var secondaryMgr = loadMsgHelper.secondaryMgr;

var cluster = require('cluster');

test('secondary test on forking', function(t) {
if (cluster.isMaster && !process.argv[2]) {
var msg = f('Master is %s', process.pid);
if (cluster.isMaster && !process.argv[2]) {
var msg = f('Master is %s', process.pid);
console.log(msg);
cluster.setupMaster({
exec: __filename,
args: ['second_invoke'],
silent: false,
});
cluster.fork();
cluster.on('online', function(worker) {
msg = f('Worker %s has started', worker.process.pid);
console.log(msg);
cluster.setupMaster({
exec: __filename,
args: ['second_invoke'],
silent: false,
});
cluster.fork();
cluster.on('online', function(worker) {
msg = f('Worker %s has started', worker.process.pid);
console.log(msg);
});
cluster.on('exit', function(worker) {
msg = f('Worker %s has completed', worker.process.pid);
console.log(msg);
t.end();
});
} else if (cluster.isWorker) {
});
cluster.on('exit', function(worker) {
msg = f('Worker %s has completed', worker.process.pid);
console.log(msg);
});
} else if (cluster.isWorker) {
var test = require('tap').test;
test('secondary test on forking', function(t) {
t.equal(process.argv[2], 'second_invoke', 'worker in the second invoke');
async.forEachOfSeries(wellKnownLangs, function(lang, ix, callback) {
secondaryMgr(__dirname, lang, t, helper.AML_ALL, true,
Expand All @@ -45,11 +44,8 @@ test('secondary test on forking', function(t) {
if (err) t.fail('language iteration failed.');
else t.pass('language iteration succeeds.');
t.end();
process.exit(0);
// process should now exit cleanly
process.disconnect();
});
} else {
t.pass('default case');
t.end();
}
});

});
}

0 comments on commit 95f48e5

Please sign in to comment.