summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-03-24 23:16:45 +0000
committerGitHub <noreply@github.com>2024-03-24 16:16:45 -0700
commitd043dd86f73f93691c9d9032b38ac94ac16a8793 (patch)
tree575102a4f7652fdb6538ffcead590bedf67237b8 /cli/js
parentd263c632e3d5a91fd6f9fffc598128d87c5621cd (diff)
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
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/40_bench.js5
-rw-r--r--cli/js/40_test.js5
2 files changed, 10 insertions, 0 deletions
diff --git a/cli/js/40_bench.js b/cli/js/40_bench.js
index e1373c990..a94c782fc 100644
--- a/cli/js/40_bench.js
+++ b/cli/js/40_bench.js
@@ -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 = {
diff --git a/cli/js/40_test.js b/cli/js/40_test.js
index 2e448e847..d93228940 100644
--- a/cli/js/40_test.js
+++ b/cli/js/40_test.js
@@ -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,