summaryrefslogtreecommitdiff
path: root/cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-02-10 13:22:13 -0700
committerGitHub <noreply@github.com>2024-02-10 20:22:13 +0000
commitf5e46c9bf2f50d66a953fa133161fc829cecff06 (patch)
tree8faf2f5831c1c7b11d842cd9908d141082c869a5 /cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js
parentd2477f780630a812bfd65e3987b70c0d309385bb (diff)
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests -> tests, and updates of relative paths for files. This is the first step towards aggregate all of the integration test files under tests/, which will lead to a set of integration tests that can run without the CLI binary being built. While we could leave these tests under `cli`, it would require us to keep a more complex directory structure for the various test runners. In addition, we have a lot of complexity to ignore various test files in the `cli` project itself (cargo publish exclusion rules, autotests = false, etc). And finally, the `tests/` folder will eventually house the `test_ffi`, `test_napi` and other testing code, reducing the size of the root repo directory. For easier review, the extremely large and noisy "move" is in the first commit (with no changes -- just a move), while the remainder of the changes to actual files is in the second commit.
Diffstat (limited to 'cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js')
-rw-r--r--cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js223
1 files changed, 0 insertions, 223 deletions
diff --git a/cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js b/cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js
deleted file mode 100644
index 89ff02260..000000000
--- a/cli/tests/node_compat/test/parallel/test-child-process-spawnsync-validation-errors.js
+++ /dev/null
@@ -1,223 +0,0 @@
-// deno-fmt-ignore-file
-// deno-lint-ignore-file
-
-// Copyright Joyent and Node contributors. All rights reserved. MIT license.
-// Taken from Node 18.12.1
-// This file is automatically generated by `tools/node_compat/setup.ts`. Do not modify this file manually.
-
-'use strict';
-const common = require('../common');
-const assert = require('assert');
-const spawnSync = require('child_process').spawnSync;
-const signals = require('os').constants.signals;
-const rootUser = common.isWindows ? false :
- common.isIBMi ? true : process.getuid() === 0;
-
-const invalidArgTypeError = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' };
-const invalidRangeError = { code: 'ERR_OUT_OF_RANGE', name: 'RangeError' };
-
-function pass(option, value) {
- // Run the command with the specified option. Since it's not a real command,
- // spawnSync() should run successfully but return an ENOENT error.
- const child = spawnSync('not_a_real_command', { [option]: value });
-
- assert.strictEqual(child.error.code, 'ENOENT');
-}
-
-function fail(option, value, message) {
- assert.throws(() => {
- spawnSync('not_a_real_command', { [option]: value });
- }, message);
-}
-
-{
- // Validate the cwd option
- pass('cwd', undefined);
- pass('cwd', null);
- pass('cwd', __dirname);
- fail('cwd', 0, invalidArgTypeError);
- fail('cwd', 1, invalidArgTypeError);
- fail('cwd', true, invalidArgTypeError);
- fail('cwd', false, invalidArgTypeError);
- fail('cwd', [], invalidArgTypeError);
- fail('cwd', {}, invalidArgTypeError);
- fail('cwd', common.mustNotCall(), invalidArgTypeError);
-}
-
-{
- // Validate the detached option
- pass('detached', undefined);
- pass('detached', null);
- pass('detached', true);
- pass('detached', false);
- fail('detached', 0, invalidArgTypeError);
- fail('detached', 1, invalidArgTypeError);
- fail('detached', __dirname, invalidArgTypeError);
- fail('detached', [], invalidArgTypeError);
- fail('detached', {}, invalidArgTypeError);
- fail('detached', common.mustNotCall(), invalidArgTypeError);
-}
-
-if (!common.isWindows) {
- {
- // Validate the uid option
- if (!rootUser) {
- pass('uid', undefined);
- pass('uid', null);
- pass('uid', process.getuid());
- fail('uid', __dirname, invalidArgTypeError);
- fail('uid', true, invalidArgTypeError);
- fail('uid', false, invalidArgTypeError);
- fail('uid', [], invalidArgTypeError);
- fail('uid', {}, invalidArgTypeError);
- fail('uid', common.mustNotCall(), invalidArgTypeError);
- fail('uid', NaN, invalidArgTypeError);
- fail('uid', Infinity, invalidArgTypeError);
- fail('uid', 3.1, invalidArgTypeError);
- fail('uid', -3.1, invalidArgTypeError);
- }
- }
-
- {
- // Validate the gid option
- if (process.getgid() !== 0) {
- pass('gid', undefined);
- pass('gid', null);
- pass('gid', process.getgid());
- fail('gid', __dirname, invalidArgTypeError);
- fail('gid', true, invalidArgTypeError);
- fail('gid', false, invalidArgTypeError);
- fail('gid', [], invalidArgTypeError);
- fail('gid', {}, invalidArgTypeError);
- fail('gid', common.mustNotCall(), invalidArgTypeError);
- fail('gid', NaN, invalidArgTypeError);
- fail('gid', Infinity, invalidArgTypeError);
- fail('gid', 3.1, invalidArgTypeError);
- fail('gid', -3.1, invalidArgTypeError);
- }
- }
-}
-
-{
- // Validate the shell option
- pass('shell', undefined);
- pass('shell', null);
- pass('shell', false);
- fail('shell', 0, invalidArgTypeError);
- fail('shell', 1, invalidArgTypeError);
- fail('shell', [], invalidArgTypeError);
- fail('shell', {}, invalidArgTypeError);
- fail('shell', common.mustNotCall(), invalidArgTypeError);
-}
-
-{
- // Validate the argv0 option
- pass('argv0', undefined);
- pass('argv0', null);
- pass('argv0', 'myArgv0');
- fail('argv0', 0, invalidArgTypeError);
- fail('argv0', 1, invalidArgTypeError);
- fail('argv0', true, invalidArgTypeError);
- fail('argv0', false, invalidArgTypeError);
- fail('argv0', [], invalidArgTypeError);
- fail('argv0', {}, invalidArgTypeError);
- fail('argv0', common.mustNotCall(), invalidArgTypeError);
-}
-
-{
- // Validate the windowsHide option
- pass('windowsHide', undefined);
- pass('windowsHide', null);
- pass('windowsHide', true);
- pass('windowsHide', false);
- fail('windowsHide', 0, invalidArgTypeError);
- fail('windowsHide', 1, invalidArgTypeError);
- fail('windowsHide', __dirname, invalidArgTypeError);
- fail('windowsHide', [], invalidArgTypeError);
- fail('windowsHide', {}, invalidArgTypeError);
- fail('windowsHide', common.mustNotCall(), invalidArgTypeError);
-}
-
-{
- // Validate the windowsVerbatimArguments option
- pass('windowsVerbatimArguments', undefined);
- pass('windowsVerbatimArguments', null);
- pass('windowsVerbatimArguments', true);
- pass('windowsVerbatimArguments', false);
- fail('windowsVerbatimArguments', 0, invalidArgTypeError);
- fail('windowsVerbatimArguments', 1, invalidArgTypeError);
- fail('windowsVerbatimArguments', __dirname, invalidArgTypeError);
- fail('windowsVerbatimArguments', [], invalidArgTypeError);
- fail('windowsVerbatimArguments', {}, invalidArgTypeError);
- fail('windowsVerbatimArguments', common.mustNotCall(), invalidArgTypeError);
-}
-
-{
- // Validate the timeout option
- pass('timeout', undefined);
- pass('timeout', null);
- pass('timeout', 1);
- pass('timeout', 0);
- fail('timeout', -1, invalidRangeError);
- fail('timeout', true, invalidRangeError);
- fail('timeout', false, invalidRangeError);
- fail('timeout', __dirname, invalidRangeError);
- fail('timeout', [], invalidRangeError);
- fail('timeout', {}, invalidRangeError);
- fail('timeout', common.mustNotCall(), invalidRangeError);
- fail('timeout', NaN, invalidRangeError);
- fail('timeout', Infinity, invalidRangeError);
- fail('timeout', 3.1, invalidRangeError);
- fail('timeout', -3.1, invalidRangeError);
-}
-
-{
- // Validate the maxBuffer option
- pass('maxBuffer', undefined);
- pass('maxBuffer', null);
- pass('maxBuffer', 1);
- pass('maxBuffer', 0);
- pass('maxBuffer', Infinity);
- pass('maxBuffer', 3.14);
- fail('maxBuffer', -1, invalidRangeError);
- fail('maxBuffer', NaN, invalidRangeError);
- fail('maxBuffer', -Infinity, invalidRangeError);
- fail('maxBuffer', true, invalidRangeError);
- fail('maxBuffer', false, invalidRangeError);
- fail('maxBuffer', __dirname, invalidRangeError);
- fail('maxBuffer', [], invalidRangeError);
- fail('maxBuffer', {}, invalidRangeError);
- fail('maxBuffer', common.mustNotCall(), invalidRangeError);
-}
-
-{
- // Validate the killSignal option
- const unknownSignalErr = { code: 'ERR_UNKNOWN_SIGNAL', name: 'TypeError' };
-
- pass('killSignal', undefined);
- pass('killSignal', null);
- pass('killSignal', 'SIGKILL');
- fail('killSignal', 'SIGNOTAVALIDSIGNALNAME', unknownSignalErr);
- fail('killSignal', true, invalidArgTypeError);
- fail('killSignal', false, invalidArgTypeError);
- fail('killSignal', [], invalidArgTypeError);
- fail('killSignal', {}, invalidArgTypeError);
- fail('killSignal', common.mustNotCall(), invalidArgTypeError);
-
- // Invalid signal names and numbers should fail
- fail('killSignal', 500, unknownSignalErr);
- fail('killSignal', 0, unknownSignalErr);
- fail('killSignal', -200, unknownSignalErr);
- fail('killSignal', 3.14, unknownSignalErr);
-
- Object.getOwnPropertyNames(Object.prototype).forEach((property) => {
- fail('killSignal', property, unknownSignalErr);
- });
-
- // Valid signal names and numbers should pass
- for (const signalName in signals) {
- pass('killSignal', signals[signalName]);
- pass('killSignal', signalName);
- pass('killSignal', signalName.toLowerCase());
- }
-}