summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-02-10 12:08:49 -0800
committerJames M Snell <jasnell@gmail.com>2017-04-27 15:44:14 -0700
commit76327613aff38f53c017eb26b2209fb1ca2b81b9 (patch)
tree156f42a6147e165d5082e3d9606e73c07910cd1c /test
parentf0b702555aacc814da28a018277d56e5f79f10d1 (diff)
downloadandroid-node-v8-76327613aff38f53c017eb26b2209fb1ca2b81b9.tar.gz
android-node-v8-76327613aff38f53c017eb26b2209fb1ca2b81b9.tar.bz2
android-node-v8-76327613aff38f53c017eb26b2209fb1ca2b81b9.zip
errors, child_process: migrate to using internal/errors
PR-URL: https://github.com/nodejs/node/pull/11300 Ref: https://github.com/nodejs/node/issues/11273 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-child-process-constructor.js4
-rw-r--r--test/parallel/test-child-process-send-type-error.js2
-rw-r--r--test/parallel/test-child-process-spawnsync-kill-signal.js2
-rw-r--r--test/parallel/test-child-process-spawnsync-validation-errors.js3
-rw-r--r--test/parallel/test-child-process-stdio.js2
-rw-r--r--test/parallel/test-child-process-validate-stdio.js18
6 files changed, 15 insertions, 16 deletions
diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js
index 7e86ad198f..c495f1895d 100644
--- a/test/parallel/test-child-process-constructor.js
+++ b/test/parallel/test-child-process-constructor.js
@@ -1,6 +1,6 @@
'use strict';
-require('../common');
+const common = require('../common');
const assert = require('assert');
const { ChildProcess } = require('child_process');
assert.strictEqual(typeof ChildProcess, 'function');
@@ -64,6 +64,6 @@ assert(Number.isInteger(child.pid));
// try killing with invalid signal
assert.throws(() => {
child.kill('foo');
-}, /^Error: Unknown signal: foo$/);
+}, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
assert.strictEqual(child.kill(), true);
diff --git a/test/parallel/test-child-process-send-type-error.js b/test/parallel/test-child-process-send-type-error.js
index dc305c3689..40c415666f 100644
--- a/test/parallel/test-child-process-send-type-error.js
+++ b/test/parallel/test-child-process-send-type-error.js
@@ -6,7 +6,7 @@ const cp = require('child_process');
function fail(proc, args) {
assert.throws(() => {
proc.send.apply(proc, args);
- }, /"options" argument must be an object/);
+ }, common.expectsError({code: 'ERR_INVALID_ARG_TYPE', type: TypeError}));
}
let target = process;
diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js
index 906718e5b7..1b8b267ff6 100644
--- a/test/parallel/test-child-process-spawnsync-kill-signal.js
+++ b/test/parallel/test-child-process-spawnsync-kill-signal.js
@@ -21,7 +21,7 @@ if (process.argv[2] === 'child') {
// Verify that an error is thrown for unknown signals.
assert.throws(() => {
spawn('SIG_NOT_A_REAL_SIGNAL');
- }, /Error: Unknown signal: SIG_NOT_A_REAL_SIGNAL/);
+ }, common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }));
// Verify that the default kill signal is SIGTERM.
{
diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js
index 83b114f7ba..7ac18ba755 100644
--- a/test/parallel/test-child-process-spawnsync-validation-errors.js
+++ b/test/parallel/test-child-process-spawnsync-validation-errors.js
@@ -185,7 +185,8 @@ if (!common.isWindows) {
{
// Validate the killSignal option
const typeErr = /^TypeError: "killSignal" must be a string or number$/;
- const unknownSignalErr = /^Error: Unknown signal:/;
+ const unknownSignalErr =
+ common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' });
pass('killSignal', undefined);
pass('killSignal', null);
diff --git a/test/parallel/test-child-process-stdio.js b/test/parallel/test-child-process-stdio.js
index 00c002e89d..eda2d8841a 100644
--- a/test/parallel/test-child-process-stdio.js
+++ b/test/parallel/test-child-process-stdio.js
@@ -42,4 +42,4 @@ assert.deepStrictEqual(options, {stdio: 'ignore'});
assert.throws(() => {
common.spawnPwd({stdio: ['pipe', 'pipe', 'pipe', 'ipc', 'ipc']});
-}, /^Error: Child process can have only one IPC pipe$/);
+}, common.expectsError({code: 'ERR_IPC_ONE_PIPE', type: Error}));
diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js
index 384efdf15a..c6a9bd8e19 100644
--- a/test/parallel/test-child-process-validate-stdio.js
+++ b/test/parallel/test-child-process-validate-stdio.js
@@ -1,19 +1,18 @@
'use strict';
// Flags: --expose_internals
-require('../common');
+const common = require('../common');
const assert = require('assert');
const _validateStdio = require('internal/child_process')._validateStdio;
+const expectedError =
+ common.expectsError({code: 'ERR_INVALID_OPT_VALUE', type: TypeError});
+
// should throw if string and not ignore, pipe, or inherit
-assert.throws(function() {
- _validateStdio('foo');
-}, /Incorrect value of stdio option/);
+assert.throws(() => _validateStdio('foo'), expectedError);
// should throw if not a string or array
-assert.throws(function() {
- _validateStdio(600);
-}, /Incorrect value of stdio option/);
+assert.throws(() => _validateStdio(600), expectedError);
// should populate stdio with undefined if len < 3
{
@@ -27,9 +26,8 @@ assert.throws(function() {
// should throw if stdio has ipc and sync is true
const stdio2 = ['ipc', 'ipc', 'ipc'];
-assert.throws(function() {
- _validateStdio(stdio2, true);
-}, /You cannot use IPC with synchronous forks/);
+assert.throws(() => _validateStdio(stdio2, true),
+ common.expectsError({code: 'ERR_IPC_SYNC_FORK', type: Error}));
{
const stdio3 = [process.stdin, process.stdout, process.stderr];