diff options
author | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-07-15 03:30:28 +0300 |
---|---|---|
committer | Vse Mozhet Byt <vsemozhetbyt@gmail.com> | 2017-07-21 20:40:52 +0300 |
commit | 4f875222445b07016a8294fa5a5bf7418c735489 (patch) | |
tree | fcb4996be68507c06dec905eacff6300d74319e7 /test/parallel/test-process-exit-code.js | |
parent | 43bd47c352a368db6051b1017225abace015d3c9 (diff) | |
download | android-node-v8-4f875222445b07016a8294fa5a5bf7418c735489.tar.gz android-node-v8-4f875222445b07016a8294fa5a5bf7418c735489.tar.bz2 android-node-v8-4f875222445b07016a8294fa5a5bf7418c735489.zip |
doc, lib, test: do not re-require needlessly
PR-URL: https://github.com/nodejs/node/pull/14244
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Diffstat (limited to 'test/parallel/test-process-exit-code.js')
-rw-r--r-- | test/parallel/test-process-exit-code.js | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/test/parallel/test-process-exit-code.js b/test/parallel/test-process-exit-code.js index e84be0aead..4deebb54a1 100644 --- a/test/parallel/test-process-exit-code.js +++ b/test/parallel/test-process-exit-code.js @@ -83,22 +83,23 @@ function child5() { } function parent() { + const { spawn } = require('child_process'); + const node = process.execPath; + const f = __filename; + const option = { stdio: [ 0, 1, 'ignore' ] }; + + const test = (arg, exit) => { + spawn(node, [f, arg], option).on('exit', (code) => { + assert.strictEqual( + code, exit, + `wrong exit for ${arg}\nexpected:${exit} but got:${code}`); + console.log('ok - %s exited with %d', arg, exit); + }); + }; + test('child1', 42); test('child2', 42); test('child3', 0); test('child4', 1); test('child5', 99); } - -function test(arg, exit) { - const spawn = require('child_process').spawn; - const node = process.execPath; - const f = __filename; - const option = { stdio: [ 0, 1, 'ignore' ] }; - spawn(node, [f, arg], option).on('exit', function(code) { - assert.strictEqual( - code, exit, - `wrong exit for ${arg}\nexpected:${exit} but got:${code}`); - console.log('ok - %s exited with %d', arg, exit); - }); -} |