diff options
Diffstat (limited to 'test/parallel/test-child-process-server-close.js')
-rw-r--r-- | test/parallel/test-child-process-server-close.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/parallel/test-child-process-server-close.js b/test/parallel/test-child-process-server-close.js index d70926f2e8..8ad32b4bbf 100644 --- a/test/parallel/test-child-process-server-close.js +++ b/test/parallel/test-child-process-server-close.js @@ -1,12 +1,29 @@ 'use strict'; const common = require('../common'); -const { spawn } = require('child_process'); +const assert = require('assert'); +const { fork, spawn } = require('child_process'); const net = require('net'); const tmpdir = require('../common/tmpdir'); -tmpdir.refresh(); +// Run in a child process because the PIPE file descriptor stays open until +// Node.js completes, blocking the tmpdir and preventing cleanup. + +if (process.argv[2] !== 'child') { + // Parent + tmpdir.refresh(); + + // Run test + const child = fork(__filename, ['child'], { stdio: 'inherit' }); + child.on('exit', common.mustCall(function(code) { + assert.strictEqual(code, 0); + })); + + return; +} + +// Child const server = net.createServer((conn) => { spawn(process.execPath, ['-v'], { stdio: ['ignore', conn, 'ignore'] |