diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-06-24 12:00:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 12:00:53 +0200 |
commit | d39094913e91e5193f63459d9c5ca6ddc7779477 (patch) | |
tree | 597f66d8637644abf2a10422cf7abb35ea3c5598 /runtime/js/40_testing.js | |
parent | 215f3d4c8e5f694bc6341ca5307b8a3794a32de0 (diff) |
fix: don't error if Deno.bench() or Deno.test() are used in run subcommand (#14946)
Diffstat (limited to 'runtime/js/40_testing.js')
-rw-r--r-- | runtime/js/40_testing.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 3850e411d..13cdcd32e 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -554,6 +554,7 @@ const tests = []; /** @type {BenchDescription[]} */ const benchDescs = []; + let isTestOrBenchSubcommand = false; // Main test function provided by Deno. function test( @@ -561,6 +562,10 @@ optionsOrFn, maybeFn, ) { + if (!isTestOrBenchSubcommand) { + return; + } + let testDef; const defaults = { ignore: false, @@ -669,6 +674,10 @@ optionsOrFn, maybeFn, ) { + if (!isTestOrBenchSubcommand) { + return; + } + core.opSync("op_bench_check_unstable"); let benchDesc; const defaults = { @@ -1043,6 +1052,13 @@ return core.opSync("op_bench_now"); } + // This function is called by Rust side if we're in `deno test` or + // `deno bench` subcommand. If this function is not called then `Deno.test()` + // and `Deno.bench()` become noops. + function enableTestAndBench() { + isTestOrBenchSubcommand = true; + } + async function runTests({ filter = null, shuffle = null, @@ -1507,6 +1523,7 @@ window.__bootstrap.internals = { ...window.__bootstrap.internals ?? {}, + enableTestAndBench, runTests, runBenchmarks, }; |