diff options
author | Brian White <mscdex@mscdex.net> | 2017-06-10 14:15:51 -0400 |
---|---|---|
committer | Brian White <mscdex@mscdex.net> | 2017-06-13 19:19:16 -0400 |
commit | 448c4c62d2b413226dfdef03d6f8d243de0984a3 (patch) | |
tree | 5868b23249b4f36a5debb3e2abe448b28c932519 /test/parallel/test-child-process-spawnsync-kill-signal.js | |
parent | 9dc3f936c78621c0e1781f65b336bff920187a82 (diff) | |
download | node-new-448c4c62d2b413226dfdef03d6f8d243de0984a3.tar.gz |
child_process: do not extend result for *Sync()
PR-URL: https://github.com/nodejs/node/pull/13601
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/parallel/test-child-process-spawnsync-kill-signal.js')
-rw-r--r-- | test/parallel/test-child-process-spawnsync-kill-signal.js | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js index 1b8b267ff6..f199d288a1 100644 --- a/test/parallel/test-child-process-spawnsync-kill-signal.js +++ b/test/parallel/test-child-process-spawnsync-kill-signal.js @@ -1,3 +1,4 @@ +// Flags: --expose_internals 'use strict'; const common = require('../common'); const assert = require('assert'); @@ -6,13 +7,22 @@ const cp = require('child_process'); if (process.argv[2] === 'child') { setInterval(common.noop, 1000); } else { + const internalCp = require('internal/child_process'); + const oldSpawnSync = internalCp.spawnSync; const { SIGKILL } = process.binding('constants').os.signals; - function spawn(killSignal) { + function spawn(killSignal, beforeSpawn) { + if (beforeSpawn) { + internalCp.spawnSync = common.mustCall(function(opts) { + beforeSpawn(opts); + return oldSpawnSync(opts); + }); + } const child = cp.spawnSync(process.execPath, [__filename, 'child'], {killSignal, timeout: 100}); - + if (beforeSpawn) + internalCp.spawnSync = oldSpawnSync; assert.strictEqual(child.status, null); assert.strictEqual(child.error.code, 'ETIMEDOUT'); return child; @@ -25,26 +35,30 @@ if (process.argv[2] === 'child') { // Verify that the default kill signal is SIGTERM. { - const child = spawn(); + const child = spawn(undefined, (opts) => { + assert.strictEqual(opts.options.killSignal, undefined); + }); assert.strictEqual(child.signal, 'SIGTERM'); - assert.strictEqual(child.options.killSignal, undefined); } // Verify that a string signal name is handled properly. { - const child = spawn('SIGKILL'); + const child = spawn('SIGKILL', (opts) => { + assert.strictEqual(opts.options.killSignal, SIGKILL); + }); assert.strictEqual(child.signal, 'SIGKILL'); - assert.strictEqual(child.options.killSignal, SIGKILL); } // Verify that a numeric signal is handled properly. { - const child = spawn(SIGKILL); - assert.strictEqual(typeof SIGKILL, 'number'); + + const child = spawn(SIGKILL, (opts) => { + assert.strictEqual(opts.options.killSignal, SIGKILL); + }); + assert.strictEqual(child.signal, 'SIGKILL'); - assert.strictEqual(child.options.killSignal, SIGKILL); } } |