summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/node_compat/config.jsonc18
-rw-r--r--cli/tests/node_compat/test/parallel/test-child-process-fork-ref.js72
-rw-r--r--cli/tests/node_compat/test/parallel/test-child-process-fork-ref2.js63
-rw-r--r--cli/tests/node_compat/test/parallel/test-child-process-ipc-next-tick.js52
4 files changed, 194 insertions, 11 deletions
diff --git a/cli/tests/node_compat/config.jsonc b/cli/tests/node_compat/config.jsonc
index 943be9759..a29d75a19 100644
--- a/cli/tests/node_compat/config.jsonc
+++ b/cli/tests/node_compat/config.jsonc
@@ -38,6 +38,10 @@
"test-child-process-execfile.js",
"test-child-process-execsync-maxbuf.js",
"test-child-process-exit-code.js",
+ // TODO(littledivy): windows ipc streams not yet implemented
+ "test-child-process-fork-ref.js",
+ "test-child-process-fork-ref2.js",
+ "test-child-process-ipc-next-tick.js",
"test-child-process-ipc.js",
"test-child-process-spawnsync-env.js",
"test-child-process-stdio-inherit.js",
@@ -109,9 +113,7 @@
"test-zlib-zero-windowBits.js"
],
"pummel": [],
- "sequential": [
- "test-child-process-exit.js"
- ]
+ "sequential": ["test-child-process-exit.js"]
},
"tests": {
"common": [
@@ -138,11 +140,7 @@
"print-chars.js",
"x.txt"
],
- "fixtures/keys": [
- "agent1-cert.pem",
- "agent1-key.pem",
- "ca1-cert.pem"
- ],
+ "fixtures/keys": ["agent1-cert.pem", "agent1-key.pem", "ca1-cert.pem"],
"internet": [
"test-dns-any.js",
"test-dns-idna2008.js",
@@ -695,9 +693,7 @@
"test-tty-stdout-end.js"
],
"pummel": [],
- "sequential": [
- "test-child-process-exit.js"
- ]
+ "sequential": ["test-child-process-exit.js"]
},
"windowsIgnore": {
"parallel": [
diff --git a/cli/tests/node_compat/test/parallel/test-child-process-fork-ref.js b/cli/tests/node_compat/test/parallel/test-child-process-fork-ref.js
new file mode 100644
index 000000000..37c186af8
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-child-process-fork-ref.js
@@ -0,0 +1,72 @@
+// 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.
+
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+// Ignore on Windows.
+if (process.platform === 'win32') {
+ process.exit(0);
+}
+
+require('../common');
+const assert = require('assert');
+const fork = require('child_process').fork;
+
+if (process.argv[2] === 'child') {
+ process.send('1');
+
+ // Check that child don't instantly die
+ setTimeout(function() {
+ process.send('2');
+ }, 200);
+
+ process.on('disconnect', function() {
+ process.stdout.write('3');
+ });
+
+} else {
+ const child = fork(__filename, ['child'], { silent: true });
+
+ const ipc = [];
+ let stdout = '';
+
+ child.on('message', function(msg) {
+ ipc.push(msg);
+
+ if (msg === '2') child.disconnect();
+ });
+
+ child.stdout.on('data', function(chunk) {
+ stdout += chunk;
+ });
+
+ child.once('exit', function() {
+ assert.deepStrictEqual(ipc, ['1', '2']);
+ assert.strictEqual(stdout, '3');
+ });
+}
diff --git a/cli/tests/node_compat/test/parallel/test-child-process-fork-ref2.js b/cli/tests/node_compat/test/parallel/test-child-process-fork-ref2.js
new file mode 100644
index 000000000..da59d9378
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-child-process-fork-ref2.js
@@ -0,0 +1,63 @@
+// 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.
+
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+'use strict';
+
+// Ignore on Windows.
+if (process.platform === 'win32') {
+ process.exit(0);
+}
+
+const {
+ mustCall,
+ mustNotCall,
+ platformTimeout,
+} = require('../common');
+const fork = require('child_process').fork;
+const debug = require('util').debuglog('test');
+
+if (process.argv[2] === 'child') {
+ debug('child -> call disconnect');
+ process.disconnect();
+
+ setTimeout(() => {
+ debug('child -> will this keep it alive?');
+ process.on('message', mustNotCall());
+ }, platformTimeout(400));
+
+} else {
+ const child = fork(__filename, ['child']);
+
+ child.on('disconnect', mustCall(() => {
+ debug('parent -> disconnect');
+ }));
+
+ child.once('exit', mustCall(() => {
+ debug('parent -> exit');
+ }));
+}
diff --git a/cli/tests/node_compat/test/parallel/test-child-process-ipc-next-tick.js b/cli/tests/node_compat/test/parallel/test-child-process-ipc-next-tick.js
new file mode 100644
index 000000000..d255a0a64
--- /dev/null
+++ b/cli/tests/node_compat/test/parallel/test-child-process-ipc-next-tick.js
@@ -0,0 +1,52 @@
+// 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';
+
+// Ignore on Windows.
+if (process.platform === 'win32') {
+ process.exit(0);
+}
+
+const common = require('../common');
+const assert = require('assert');
+const cp = require('child_process');
+const NUM_MESSAGES = 10;
+const values = [];
+
+for (let i = 0; i < NUM_MESSAGES; ++i) {
+ values[i] = i;
+}
+
+if (process.argv[2] === 'child') {
+ const received = values.map(() => { return false; });
+
+ process.on('uncaughtException', common.mustCall((err) => {
+ received[err] = true;
+ const done = received.every((element) => { return element === true; });
+
+ if (done)
+ process.disconnect();
+ }, NUM_MESSAGES));
+
+ process.on('message', (msg) => {
+ // If messages are handled synchronously, throwing should break the IPC
+ // message processing.
+ throw msg;
+ });
+
+ process.send('ready');
+} else {
+ const child = cp.fork(__filename, ['child']);
+
+ child.on('message', common.mustCall((msg) => {
+ assert.strictEqual(msg, 'ready');
+ values.forEach((value) => {
+ child.send(value);
+ });
+ }));
+}