Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #56 from tomhughes/close-sockets
Make test close listening sockets instead of just removing them
  • Loading branch information
eriktrom committed May 7, 2017
2 parents 20161e8 + 07795bc commit 36613c1
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 36613c1

Please sign in to comment.