Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node/test): disable Deno test sanitizers #22480

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ext/node/polyfills/testing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class NodeTestContext {
await prepared.fn(newNodeTextContext);
},
ignore: prepared.options.todo || prepared.options.skip,
sanitizeExit: false,
sanitizeOps: false,
sanitizeResources: false,
}).then(() => undefined);
}

Expand Down Expand Up @@ -131,6 +134,9 @@ function prepareDenoTest(name, options, fn, overrides) {
fn: wrapTestFn(prepared.fn, resolve),
only: prepared.options.only,
ignore: prepared.options.todo || prepared.options.skip,
sanitizeExit: false,
sanitizeOps: false,
sanitizeResources: false,
};
Deno.test(denoTestOptions);
return promise;
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/node_compat_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ itest!(node_test_module {
exit_code: 1,
http_server: true,
});

itest!(node_test_module_no_sanitizers {
args: "test -A --no-check node/test_no_sanitizers/test.js",
output: "node/test_no_sanitizers/test.out",
envs: env_vars_for_npm_tests(),
exit_code: 123,
http_server: true,
});
28 changes: 28 additions & 0 deletions tests/testdata/node/test_no_sanitizers/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import test from "node:test";

test("should not complain about resource and op sanitizers", async (t) => {
// resource
const _file1 = Deno.open("welcome.ts");

await t.test("nested test", () => {
// resource
const _file2 = Deno.open("cat.ts");

// op
crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode("a".repeat(1_000_000)),
);
});

// op
crypto.subtle.digest(
"SHA-256",
new TextEncoder().encode("a".repeat(1_000_000)),
);
});

test("should allow exit", () => {
// no exit sanitizers
Deno.exit(123);
});
5 changes: 5 additions & 0 deletions tests/testdata/node/test_no_sanitizers/test.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
running 2 tests from ./node/test_no_sanitizers/test.js
should not complain about resource and op sanitizers ...
nested test ... ok ([WILDCARD])
should not complain about resource and op sanitizers ... ok ([WILDCARD])
should allow exit ...
Loading