test: fix test-cluster-eaccess to work on windows

pull/41362/head
Timothy J Fontaine 2013-12-31 11:57:13 -08:00
parent 3e9f2e61db
commit 6f8aa24d1e
1 changed files with 20 additions and 17 deletions

View File

@ -27,14 +27,28 @@ var path = require('path');
var fs = require('fs');
var net = require('net');
// No win32 support so far
if (process.platform === 'win32')
return;
var socketPath = path.join(common.fixturesDir, 'socket-path');
if (cluster.isMaster) {
cluster.fork();
var worker = cluster.fork();
var gotError = 0;
worker.on('message', function(err) {
gotError++;
console.log(err);
if (process.platform === 'win32')
assert.strictEqual('EACCES', err.code);
else
assert.strictEqual('EADDRINUSE', err.code);
worker.disconnect();
});
process.on('exit', function() {
console.log('master exited');
try {
fs.unlinkSync(socketPath);
} catch (e) {
}
assert.equal(gotError, 1);
});
} else {
fs.writeFileSync(socketPath, 'some contents');
@ -42,18 +56,7 @@ if (cluster.isMaster) {
console.log('here');
});
var gotError = 0;
server.on('error', function(err) {
gotError++;
assert(/EADDRINUSE/.test(err.message));
process.exit();
});
process.on('exit', function() {
try {
fs.unlinkSync(socketPath);
} catch (e) {
}
assert.equal(gotError, 1);
process.send(err);
});
}