node/test/parallel/test-child-process-exec-error.js
Rich Trott a6b049103a test: refactor test-child-process-exec-error
* assert.equal() -> assert.strictEqual()
* regex -> .include()
* Change variable representing a function from `fun` to idiomatic `fn`
* var -> const

PR-URL: https://github.com/nodejs/node/pull/9780
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
2016-11-27 10:16:47 -08:00

20 lines
501 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const child_process = require('child_process');
function test(fn, code) {
fn('does-not-exist', common.mustCall(function(err) {
assert.strictEqual(err.code, code);
assert(err.cmd.includes('does-not-exist'));
}));
}
if (common.isWindows) {
test(child_process.exec, 1); // exit code of cmd.exe
} else {
test(child_process.exec, 127); // exit code of /bin/sh
}
test(child_process.execFile, 'ENOENT');