Skip to content

Commit

Permalink
Make test close listening sockets instead of just removing them
Browse files Browse the repository at this point in the history
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 07795bc
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/port-finder-socket-test.js
Expand Up @@ -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({
Expand Down

0 comments on commit 07795bc

Please sign in to comment.