diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-07-06 00:36:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 18:36:43 +0200 |
commit | 407de8b8347bae165e60b9ccf0bce8050ba861fa (patch) | |
tree | 39d5c072d6a58923fa721b7aa297fcae9209a4d4 | |
parent | 0a33cc1951940ebf862361106635ff1bb39d852b (diff) |
fix(runtime): ignored tests should not cause permission changes (#11278)
-rw-r--r-- | cli/tests/integration/test_tests.rs | 6 | ||||
-rw-r--r-- | cli/tests/test/ignore_permissions.out | 6 | ||||
-rw-r--r-- | cli/tests/test/ignore_permissions.ts | 16 | ||||
-rw-r--r-- | runtime/js/40_testing.js | 9 |
4 files changed, 32 insertions, 5 deletions
diff --git a/cli/tests/integration/test_tests.rs b/cli/tests/integration/test_tests.rs index 829dcfbb3..3bc81c5d3 100644 --- a/cli/tests/integration/test_tests.rs +++ b/cli/tests/integration/test_tests.rs @@ -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, diff --git a/cli/tests/test/ignore_permissions.out b/cli/tests/test/ignore_permissions.out new file mode 100644 index 000000000..c4d273d8f --- /dev/null +++ b/cli/tests/test/ignore_permissions.out @@ -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]) + diff --git a/cli/tests/test/ignore_permissions.ts b/cli/tests/test/ignore_permissions.ts new file mode 100644 index 000000000..bd0567a46 --- /dev/null +++ b/cli/tests/test/ignore_permissions.ts @@ -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"); + }, +}); diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 3107f70a1..0106f895a 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -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"; |