From 9006e945b92bc14bd27d2fd1d468e7cc987859fd Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Fri, 28 Nov 2014 09:43:15 +1100 Subject: [PATCH] test: don't remove empty.txt on win32 on win32 we use empty.txt in the fixtures directory, otherwise we use a file constructed specifically for this test due to POSIX socket path length limitations, in which case we need to do appropriate cleanup --- test/simple/test-net-pipe-connect-errors.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/simple/test-net-pipe-connect-errors.js b/test/simple/test-net-pipe-connect-errors.js index e29d50e73e3abe..07dd4fe4a2bb75 100644 --- a/test/simple/test-net-pipe-connect-errors.js +++ b/test/simple/test-net-pipe-connect-errors.js @@ -42,19 +42,20 @@ if (process.platform === 'win32') { // use common.PIPE to ensure we stay within POSIX socket path length // restrictions, even on CI emptyTxt = common.PIPE + '.txt'; -} -function cleanup() { - try { - fs.unlinkSync(emptyTxt); - } catch (e) { - if (e.code != 'ENOENT') - throw e; + function cleanup() { + try { + fs.unlinkSync(emptyTxt); + } catch (e) { + if (e.code != 'ENOENT') + throw e; + } } + process.on('exit', cleanup); + cleanup(); + fs.writeFileSync(emptyTxt, ''); } -process.on('exit', cleanup); -cleanup(); -fs.writeFileSync(emptyTxt, ''); + var notSocketClient = net.createConnection(emptyTxt, function() { assert.ok(false); });