Skip to content

Commit

Permalink
chore: fix & update node compat config (denoland#19106)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored May 13, 2023
1 parent 68c0fcb commit 2a0c664
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 41 deletions.
3 changes: 0 additions & 3 deletions cli/tests/node_compat/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion cli/tests/node_compat/test/fixtures/run-main.js

This file was deleted.

15 changes: 0 additions & 15 deletions cli/tests/node_compat/test/parallel/test-module-run-main.js

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 15 additions & 2 deletions cli/tests/unit_node/module_test.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis.calledViaRunMain = true;
13 changes: 13 additions & 0 deletions cli/tests/unit_node/worker_threads_test.ts
Original file line number Diff line number Diff line change
@@ -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<unknown>(workerThreads.BroadcastChannel, BroadcastChannel);
});

Deno.test("[node/worker_threads] MessageChannel are MessagePort are exported", () => {
assertEquals<unknown>(workerThreads.MessageChannel, MessageChannel);
assertEquals<unknown>(workerThreads.MessagePort, MessagePort);
});
3 changes: 2 additions & 1 deletion tools/node_compat/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2a0c664

Please sign in to comment.