diff options
author | João Reis <reis@janeasystems.com> | 2019-07-30 07:50:21 +0100 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-08-10 19:22:11 -0700 |
commit | 8ef68e66d0465441a79a5dae22e480bf0d83ed25 (patch) | |
tree | 903d3a6fb4172e179717d8bc478729f621201577 /test/parallel/test-pipe-unref.js | |
parent | 0376b5b7baf627b112915183edf9e1ea2d3856b7 (diff) | |
download | android-node-v8-8ef68e66d0465441a79a5dae22e480bf0d83ed25.tar.gz android-node-v8-8ef68e66d0465441a79a5dae22e480bf0d83ed25.tar.bz2 android-node-v8-8ef68e66d0465441a79a5dae22e480bf0d83ed25.zip |
test: clean tmpdir on process exit
PR-URL: https://github.com/nodejs/node/pull/28858
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-pipe-unref.js')
-rw-r--r-- | test/parallel/test-pipe-unref.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/test/parallel/test-pipe-unref.js b/test/parallel/test-pipe-unref.js index 1e0245b544..78419a1d77 100644 --- a/test/parallel/test-pipe-unref.js +++ b/test/parallel/test-pipe-unref.js @@ -1,12 +1,29 @@ 'use strict'; const common = require('../common'); const net = require('net'); +const assert = require('assert'); +const { fork } = require('child_process'); // This test should end immediately after `unref` is called +// The pipe will stay open as Node.js completes, thus run in a child process +// so that tmpdir can be cleaned up. const tmpdir = require('../common/tmpdir'); -tmpdir.refresh(); +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 s = net.Server(); s.listen(common.PIPE); s.unref(); |