summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/js/40_testing.js18
-rw-r--r--cli/tests/testdata/bench/exit_sanitizer.out6
-rw-r--r--cli/tests/testdata/test/exit_sanitizer.out6
-rw-r--r--runtime/js/10_permissions.js3
-rw-r--r--runtime/js/30_os.js3
5 files changed, 21 insertions, 15 deletions
diff --git a/cli/js/40_testing.js b/cli/js/40_testing.js
index 81fedb83e..4f8153f5a 100644
--- a/cli/js/40_testing.js
+++ b/cli/js/40_testing.js
@@ -7,11 +7,13 @@
const core = globalThis.Deno.core;
const ops = core.ops;
-import { setExitHandler } from "ext:runtime/30_os.js";
-import { Console } from "ext:deno_console/01_console.js";
-import { serializePermissions } from "ext:runtime/10_permissions.js";
-import { setTimeout } from "ext:deno_web/02_timers.js";
-import { assert } from "ext:deno_web/00_infra.js";
+
+const internals = globalThis.__bootstrap.internals;
+const {
+ setExitHandler,
+ Console,
+ serializePermissions,
+} = internals;
const opSanitizerDelayResolveQueue = [];
let hasSetOpSanitizerDelayMacrotask = false;
@@ -445,8 +447,7 @@ function assertResources(fn) {
function assertExit(fn, isTest) {
return async function exitSanitizer(...params) {
setExitHandler((exitCode) => {
- assert(
- false,
+ throw new Error(
`${
isTest ? "Test case" : "Bench"
} attempted to exit with exit code: ${exitCode}`,
@@ -1155,8 +1156,7 @@ function wrapBenchmark(desc) {
if (desc.sanitizeExit) {
setExitHandler((exitCode) => {
- assert(
- false,
+ throw new Error(
`Bench attempted to exit with exit code: ${exitCode}`,
);
});
diff --git a/cli/tests/testdata/bench/exit_sanitizer.out b/cli/tests/testdata/bench/exit_sanitizer.out
index 501b9ce8a..9f15d3f26 100644
--- a/cli/tests/testdata/bench/exit_sanitizer.out
+++ b/cli/tests/testdata/bench/exit_sanitizer.out
@@ -5,10 +5,10 @@ runtime: deno [WILDCARD] ([WILDCARD])
[WILDCARD]/bench/exit_sanitizer.ts
benchmark time (avg) iter/s (min … max) p75 p99 p995
--------------------------------------------------------------- -----------------------------
-exit(0) error: AssertionError: Bench attempted to exit with exit code: 0
+exit(0) error: Error: Bench attempted to exit with exit code: 0
[WILDCARD]
-exit(1) error: AssertionError: Bench attempted to exit with exit code: 1
+exit(1) error: Error: Bench attempted to exit with exit code: 1
[WILDCARD]
-exit(2) error: AssertionError: Bench attempted to exit with exit code: 2
+exit(2) error: Error: Bench attempted to exit with exit code: 2
[WILDCARD]
error: Bench failed
diff --git a/cli/tests/testdata/test/exit_sanitizer.out b/cli/tests/testdata/test/exit_sanitizer.out
index 4910501fa..684001475 100644
--- a/cli/tests/testdata/test/exit_sanitizer.out
+++ b/cli/tests/testdata/test/exit_sanitizer.out
@@ -7,21 +7,21 @@ exit(2) ... FAILED ([WILDCARD])
ERRORS
exit(0) => ./test/exit_sanitizer.ts:[WILDCARD]
-error: AssertionError: Test case attempted to exit with exit code: 0
+error: Error: Test case attempted to exit with exit code: 0
Deno.exit(0);
^
at [WILDCARD]
at [WILDCARD]/test/exit_sanitizer.ts:2:8
exit(1) => ./test/exit_sanitizer.ts:[WILDCARD]
-error: AssertionError: Test case attempted to exit with exit code: 1
+error: Error: Test case attempted to exit with exit code: 1
Deno.exit(1);
^
at [WILDCARD]
at [WILDCARD]/test/exit_sanitizer.ts:6:8
exit(2) => ./test/exit_sanitizer.ts:[WILDCARD]
-error: AssertionError: Test case attempted to exit with exit code: 2
+error: Error: Test case attempted to exit with exit code: 2
Deno.exit(2);
^
at [WILDCARD]
diff --git a/runtime/js/10_permissions.js b/runtime/js/10_permissions.js
index 3004ab694..ab310930c 100644
--- a/runtime/js/10_permissions.js
+++ b/runtime/js/10_permissions.js
@@ -4,6 +4,7 @@ const core = globalThis.Deno.core;
const ops = core.ops;
import { pathFromURL } from "ext:deno_web/00_infra.js";
import { Event, EventTarget } from "ext:deno_web/02_event.js";
+const internals = globalThis.__bootstrap.internals;
const primordials = globalThis.__bootstrap.primordials;
const {
ArrayIsArray,
@@ -291,4 +292,6 @@ function serializePermissions(permissions) {
return permissions;
}
+internals.serializePermissions = serializePermissions;
+
export { Permissions, permissions, PermissionStatus, serializePermissions };
diff --git a/runtime/js/30_os.js b/runtime/js/30_os.js
index a5a55e19b..583449083 100644
--- a/runtime/js/30_os.js
+++ b/runtime/js/30_os.js
@@ -2,6 +2,7 @@
const core = globalThis.Deno.core;
const ops = core.ops;
+const internals = globalThis.__bootstrap.internals;
import { Event, EventTarget } from "ext:deno_web/02_event.js";
const primordials = globalThis.__bootstrap.primordials;
const {
@@ -106,6 +107,8 @@ function execPath() {
return ops.op_exec_path();
}
+internals.setExitHandler = setExitHandler;
+
export {
env,
execPath,