mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
fix: don't panic in test and bench if ops not available (#23055)
Fixes regression introduced in https://github.com/denoland/deno/pull/22112 that removed checks if `Deno.test` or `Deno.bench` are not used in respective subcommands. Closes https://github.com/denoland/deno/issues/23041
This commit is contained in:
parent
d263c632e3
commit
d043dd86f7
8 changed files with 34 additions and 0 deletions
|
@ -47,6 +47,11 @@ function bench(
|
|||
optionsOrFn,
|
||||
maybeFn,
|
||||
) {
|
||||
// No-op if we're not running in `deno bench` subcommand.
|
||||
if (typeof op_register_bench !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!registeredWarmupBench) {
|
||||
registeredWarmupBench = true;
|
||||
const warmupBenchDesc = {
|
||||
|
|
|
@ -198,6 +198,11 @@ function testInner(
|
|||
maybeFn,
|
||||
overrides = {},
|
||||
) {
|
||||
// No-op if we're not running in `deno test` subcommand.
|
||||
if (typeof op_register_test !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
let testDesc;
|
||||
const defaults = {
|
||||
ignore: false,
|
||||
|
|
5
tests/specs/bench/test_and_bench/__test__.jsonc
Normal file
5
tests/specs/bench/test_and_bench/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Regression test for https://github.com/denoland/deno/issues/23041
|
||||
{
|
||||
"args": "bench main.js",
|
||||
"output": "main.out"
|
||||
}
|
3
tests/specs/bench/test_and_bench/main.js
Normal file
3
tests/specs/bench/test_and_bench/main.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Deno.test("test", () => {});
|
||||
|
||||
Deno.bench("bench", () => {});
|
3
tests/specs/bench/test_and_bench/main.out
Normal file
3
tests/specs/bench/test_and_bench/main.out
Normal file
|
@ -0,0 +1,3 @@
|
|||
[WILDCARD]
|
||||
[WILDCARD]main.js
|
||||
benchmark[WILDCARD]
|
5
tests/specs/test/test_and_bench/__test__.jsonc
Normal file
5
tests/specs/test/test_and_bench/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
|||
// Regression test for https://github.com/denoland/deno/issues/23041
|
||||
{
|
||||
"args": "test main.js",
|
||||
"output": "main.out"
|
||||
}
|
3
tests/specs/test/test_and_bench/main.js
Normal file
3
tests/specs/test/test_and_bench/main.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
Deno.test("test", () => {});
|
||||
|
||||
Deno.bench("bench", () => {});
|
5
tests/specs/test/test_and_bench/main.out
Normal file
5
tests/specs/test/test_and_bench/main.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
running 1 test from ./main.js
|
||||
test ... ok ([WILDCARD])
|
||||
|
||||
ok | 1 passed | 0 failed ([WILDCARD])
|
||||
|
Loading…
Reference in a new issue