chore: use internal namespace in 40_testing.js (#21141)

Towards #21136 

- [x] assign serializePermissions, setTimeout and setExitHandler APIs to
internal namespace
- [x] remove usage of assert
This commit is contained in:
Divy Srivastava 2023-11-10 06:34:41 -08:00 committed by GitHub
parent 8ecb649182
commit 9f2e56ba96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 15 deletions

View file

@ -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}`,
);
});