Skip to content

Commit

Permalink
add test cases for options.shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Renegade334 committed Jan 2, 2025
1 parent 68e4e69 commit 1a38681
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/parallel/test-child-process-exec-enforce-shell.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const { exec, execSync } = require('child_process');

const invalidArgTypeError = {
code: 'ERR_INVALID_ARG_TYPE',
name: 'TypeError'
};

exec('echo should-be-passed-as-argument', { shell: '' }, common.mustSucceed((stdout, stderr) => {
assert.match(stdout, /should-be-passed-as-argument/);
assert.ok(!stderr);
}));

{
const ret = execSync('echo should-be-passed-as-argument', { encoding: 'utf-8', shell: '' });
assert.match(ret, /should-be-passed-as-argument/);
}

for (const fn of [exec, execSync]) {
assert.throws(() => fn('should-throw-on-boolean-shell-option', { shell: false }), invalidArgTypeError);
}

0 comments on commit 1a38681

Please sign in to comment.