From 95f48e56e64ebfaabd20d46ff88f844526606f46 Mon Sep 17 00:00:00 2001 From: Ryan Graham Date: Tue, 26 Jul 2016 14:47:04 -0700 Subject: [PATCH] test: fix empty subtest in TAP output 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. --- test/test-load-msg-forking.js | 50 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/test/test-load-msg-forking.js b/test/test-load-msg-forking.js index 3008657..e6a68e1 100644 --- a/test/test-load-msg-forking.js +++ b/test/test-load-msg-forking.js @@ -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, @@ -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(); - } -}); - + }); +}