Skip to content
Permalink
Browse files
Make test close listening sockets instead of just removing them
Without this I see the tests (with node 6.10.2) completing but then
just hanging because the servers are still listening on the sockets.
  • Loading branch information
tomhughes committed May 3, 2017
1 parent 20161e8 commit 07795bca63aa2b11ce51bb6fdd972191420c1904
Showing 1 changed file with 15 additions and 5 deletions.
@@ -54,13 +54,23 @@ function createServers (callback) {
}, callback);
}

function stopServers(callback, index) {
if (index < servers.length) {
servers[index].close(function (err) {
if (err) {
callback(err, false);
} else {
stopServers(callback, index + 1);
}
});
} else {
callback(null, true);
}
}

function cleanup(callback) {
fs.rmdirSync(badDir);
glob(path.resolve(socketDir, '*'), function (err, files) {
if (err) { callback(err); }
for (var i = 0; i < files.length; i++) { fs.unlinkSync(files[i]); }
callback(null, true);
});
stopServers(callback, 0);
}

vows.describe('portfinder').addBatch({

0 comments on commit 07795bc

Please sign in to comment.