diff --git a/test/common.js b/test/common.js index a4825daae7088c..fb81e9f0f01a68 100644 --- a/test/common.js +++ b/test/common.js @@ -28,6 +28,11 @@ exports.testDir = path.dirname(__filename); exports.fixturesDir = path.join(exports.testDir, 'fixtures'); exports.libDir = path.join(exports.testDir, '../lib'); exports.tmpDir = path.join(exports.testDir, 'tmp'); +if (process.env.NODE_PIPE_DIR === undefined) { + exports.pipeTmpDir = exports.tmpDir; +} else { + exports.pipeTmpDir = path.join(process.env.NODE_PIPE_DIR, 'NodePipeTmp'); +} exports.PORT = +process.env.NODE_COMMON_PORT || 12346; exports.opensslCli = path.join(path.dirname(process.execPath), 'openssl-cli'); @@ -35,7 +40,7 @@ if (process.platform === 'win32') { exports.PIPE = '\\\\.\\pipe\\libuv-test'; exports.opensslCli += '.exe'; } else { - exports.PIPE = exports.tmpDir + '/test.sock'; + exports.PIPE = exports.pipeTmpDir + '/test.sock'; } if (!fs.existsSync(exports.opensslCli)) exports.opensslCli = false; diff --git a/test/simple/test-cluster-eaccess.js b/test/simple/test-cluster-eaccess.js index c87dfe83b3bd6b..fb3c24b2c96425 100644 --- a/test/simple/test-cluster-eaccess.js +++ b/test/simple/test-cluster-eaccess.js @@ -27,7 +27,12 @@ var path = require('path'); var fs = require('fs'); var net = require('net'); -var socketPath = path.join(common.fixturesDir, 'socket-path'); +var socketPath = common.PIPE; +if (process.platform === 'win32') { + // for windows pipes are handled specially and we can't write to + // common.PIPE with fs.writeFileSync like we can on other platforms + socketPath = path.join(common.fixturesDir, 'socket-path'); +} if (cluster.isMaster) { var worker = cluster.fork(); diff --git a/test/simple/test-net-pipe-connect-errors.js b/test/simple/test-net-pipe-connect-errors.js index 8200a16cf0baa2..6aa3cac9f7afe6 100644 --- a/test/simple/test-net-pipe-connect-errors.js +++ b/test/simple/test-net-pipe-connect-errors.js @@ -31,7 +31,9 @@ var accessErrorFired = false; // Test if ENOTSOCK is fired when trying to connect to a file which is not // a socket. -var emptyTxt = path.join(common.fixturesDir, 'empty.txt'); +var emptyTxt = path.join(common.pipeTmpDir, 'empty.txt'); +fs.closeSync(fs.openSync(emptyTxt, 'w')); + var notSocketClient = net.createConnection(emptyTxt, function() { assert.ok(false); }); diff --git a/test/testpy/__init__.py b/test/testpy/__init__.py index 9593a1f6428a7e..545367f11f7fcc 100644 --- a/test/testpy/__init__.py +++ b/test/testpy/__init__.py @@ -48,16 +48,22 @@ def __init__(self, path, file, mode, context, config, additional=[]): self.mode = mode self.tmpdir = join(dirname(self.config.root), 'tmp') self.additional_flags = additional + if "NODE_PIPE_DIR" in os.environ: + self.pipeTmpDir = join(os.environ["NODE_PIPE_DIR"], 'NodePipeTmp') def AfterRun(self, result): # delete the whole tmp dir try: rmtree(self.tmpdir) + if self.pipeTmpDir: + rmtree(self.pipeTmpDir); except: pass # make it again. try: mkdir(self.tmpdir) + if self.pipeTmpDir: + mkdir(self.pipeTmpDir); except: pass @@ -65,6 +71,8 @@ def BeforeRun(self): # delete the whole tmp dir try: rmtree(self.tmpdir) + if self.pipeTmpDir: + rmtree(self.pipeTmpDir); except: pass # make it again. @@ -72,6 +80,8 @@ def BeforeRun(self): while not os.path.exists(self.tmpdir): try: mkdir(self.tmpdir) + if self.pipeTmpDir: + mkdir(self.pipeTmpDir); except: pass