0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(runtime): ignored tests should not cause permission changes (#11278)

This commit is contained in:
Casper Beyer 2021-07-06 00:36:43 +08:00 committed by GitHub
parent 0a33cc1951
commit 407de8b834
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 5 deletions

View file

@ -31,6 +31,12 @@ itest!(ignore {
output: "test/ignore.out",
});
itest!(ignore_permissions {
args: "test --unstable test/ignore_permissions.ts",
exit_code: 0,
output: "test/ignore_permissions.out",
});
itest!(fail {
args: "test test/fail.ts",
exit_code: 1,

View file

@ -0,0 +1,6 @@
Check [WILDCARD]/test/ignore_permissions.ts
running 1 test from [WILDCARD]/test/ignore_permissions.ts
test ignore ... ignored ([WILDCARD])
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out ([WILDCARD])

View file

@ -0,0 +1,16 @@
Deno.test({
name: "ignore",
permissions: {
read: true,
write: true,
net: true,
env: true,
run: true,
plugin: true,
hrtime: true,
},
ignore: true,
fn() {
throw new Error("unreachable");
},
});

View file

@ -192,17 +192,16 @@ finishing test case.`;
}
async function runTest({ ignore, fn, permissions }) {
if (ignore) {
return "ignored";
}
let token = null;
try {
if (permissions) {
token = pledgeTestPermissions(permissions);
}
if (ignore) {
return "ignored";
}
await fn();
return "ok";