diff --git a/cli/tests/node_compat/config.jsonc b/cli/tests/node_compat/config.jsonc index 8fbc3e921d..81463bcaf5 100644 --- a/cli/tests/node_compat/config.jsonc +++ b/cli/tests/node_compat/config.jsonc @@ -366,7 +366,6 @@ "test-http-outgoing-message-inheritance.js", "test-http-outgoing-renderHeaders.js", "test-http-outgoing-settimeout.js", - "test-module-run-main.js", "test-net-access-byteswritten.js", "test-net-better-error-messages-listen-path.js", "test-net-better-error-messages-path.js", @@ -655,8 +654,6 @@ "test-whatwg-url-override-hostname.js", "test-whatwg-url-properties.js", "test-whatwg-url-toascii.js", - "test-worker-threads-broadcast-channel.js", - "test-worker-threads-message-channel.js", "test-zlib-close-after-error.js", "test-zlib-close-after-write.js", "test-zlib-convenience-methods.js", diff --git a/cli/tests/node_compat/test/fixtures/run-main.js b/cli/tests/node_compat/test/fixtures/run-main.js deleted file mode 100644 index 9a081cbbae..0000000000 --- a/cli/tests/node_compat/test/fixtures/run-main.js +++ /dev/null @@ -1 +0,0 @@ -globalThis.foo = 42; diff --git a/cli/tests/node_compat/test/parallel/test-module-run-main.js b/cli/tests/node_compat/test/parallel/test-module-run-main.js deleted file mode 100644 index 8e30de2671..0000000000 --- a/cli/tests/node_compat/test/parallel/test-module-run-main.js +++ /dev/null @@ -1,15 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -"use strict"; - -const Module = require("module"); -const assert = require("assert/strict"); -const path = require("path"); - -const file = path.join(__dirname, "..", "fixtures", "run-main.js"); -process.argv = [process.argv[0], file]; -Module.runMain(); - -// The required file via `Module.runMain()` sets this global -assert.equal(globalThis.foo, 42); diff --git a/cli/tests/node_compat/test/parallel/test-worker-threads-broadcast-channel.js b/cli/tests/node_compat/test/parallel/test-worker-threads-broadcast-channel.js deleted file mode 100644 index a8fd3ff0e8..0000000000 --- a/cli/tests/node_compat/test/parallel/test-worker-threads-broadcast-channel.js +++ /dev/null @@ -1,9 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -"use strict"; - -const assert = require("assert/strict"); -const worker_threads = require("worker_threads"); - -assert.equal(BroadcastChannel, worker_threads.BroadcastChannel); diff --git a/cli/tests/node_compat/test/parallel/test-worker-threads-message-channel.js b/cli/tests/node_compat/test/parallel/test-worker-threads-message-channel.js deleted file mode 100644 index b831ed3fee..0000000000 --- a/cli/tests/node_compat/test/parallel/test-worker-threads-message-channel.js +++ /dev/null @@ -1,10 +0,0 @@ -// deno-fmt-ignore-file -// deno-lint-ignore-file - -"use strict"; - -const assert = require("assert/strict"); -const worker_threads = require("worker_threads"); - -assert.equal(MessageChannel, worker_threads.MessageChannel); -assert.equal(MessagePort, worker_threads.MessagePort); diff --git a/cli/tests/unit_node/module_test.ts b/cli/tests/unit_node/module_test.ts index d071ed2d18..a5c819d960 100644 --- a/cli/tests/unit_node/module_test.ts +++ b/cli/tests/unit_node/module_test.ts @@ -1,7 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. import { Module } from "node:module"; -import { assertStrictEquals } from "../../../test_util/std/testing/asserts.ts"; +import { assertEquals } from "../../../test_util/std/testing/asserts.ts"; +import process from "node:process"; Deno.test("[node/module _preloadModules] has internal require hook", () => { // Check if it's there @@ -10,5 +11,17 @@ Deno.test("[node/module _preloadModules] has internal require hook", () => { "./cli/tests/unit_node/testdata/add_global_property.js", ]); // deno-lint-ignore no-explicit-any - assertStrictEquals((globalThis as any).foo, "Hello"); + assertEquals((globalThis as any).foo, "Hello"); +}); + +Deno.test("[node/module runMain] loads module using the current process.argv", () => { + process.argv = [ + process.argv[0], + "./cli/tests/unit_node/testdata/add_global_property_run_main.js", + ]; + + // deno-lint-ignore no-explicit-any + (Module as any).runMain(); + // deno-lint-ignore no-explicit-any + assertEquals((globalThis as any).calledViaRunMain, true); }); diff --git a/cli/tests/unit_node/testdata/add_global_property_run_main.js b/cli/tests/unit_node/testdata/add_global_property_run_main.js new file mode 100644 index 0000000000..c9db1cea66 --- /dev/null +++ b/cli/tests/unit_node/testdata/add_global_property_run_main.js @@ -0,0 +1 @@ +globalThis.calledViaRunMain = true; diff --git a/cli/tests/unit_node/worker_threads_test.ts b/cli/tests/unit_node/worker_threads_test.ts new file mode 100644 index 0000000000..17de7cca1e --- /dev/null +++ b/cli/tests/unit_node/worker_threads_test.ts @@ -0,0 +1,13 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +import { assertEquals } from "../../../test_util/std/testing/asserts.ts"; +import workerThreads from "node:worker_threads"; + +Deno.test("[node/worker_threads] BroadcastChannel is exported", () => { + assertEquals(workerThreads.BroadcastChannel, BroadcastChannel); +}); + +Deno.test("[node/worker_threads] MessageChannel are MessagePort are exported", () => { + assertEquals(workerThreads.MessageChannel, MessageChannel); + assertEquals(workerThreads.MessagePort, MessagePort); +}); diff --git a/tools/node_compat/TODO.md b/tools/node_compat/TODO.md index cca14b4997..0aae01edcd 100644 --- a/tools/node_compat/TODO.md +++ b/tools/node_compat/TODO.md @@ -3,7 +3,7 @@ NOTE: This file should not be manually edited. Please edit 'cli/tests/node_compat/config.json' and run 'tools/node_compat/setup.ts' instead. -Total: 2923 +Total: 2924 - [abort/test-abort-backtrace.js](https://github.com/nodejs/node/tree/v18.12.1/test/abort/test-abort-backtrace.js) - [abort/test-abort-fatal-error.js](https://github.com/nodejs/node/tree/v18.12.1/test/abort/test-abort-fatal-error.js) @@ -281,6 +281,7 @@ Total: 2923 - [parallel/test-child-process-exec-encoding.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-exec-encoding.js) - [parallel/test-child-process-exec-std-encoding.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-exec-std-encoding.js) - [parallel/test-child-process-exec-timeout-expire.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-exec-timeout-expire.js) +- [parallel/test-child-process-exec-timeout-kill.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-exec-timeout-kill.js) - [parallel/test-child-process-exec-timeout-not-expired.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-exec-timeout-not-expired.js) - [parallel/test-child-process-execFile-promisified-abortController.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-execFile-promisified-abortController.js) - [parallel/test-child-process-execfile.js](https://github.com/nodejs/node/tree/v18.12.1/test/parallel/test-child-process-execfile.js)