1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

perf: move "cli/js/40_testing.js" out of main snapshot (#21212)

Closes https://github.com/denoland/deno/issues/21136

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Divy Srivastava 2023-11-24 19:46:16 -08:00 committed by GitHub
parent 7d8f0ae038
commit 89424f8e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 1269 additions and 1233 deletions

View file

@ -320,8 +320,16 @@ impl DenoSubcommand {
matches!(self, Self::Run(_))
}
pub fn is_test_or_jupyter(&self) -> bool {
matches!(self, Self::Test(_) | Self::Jupyter(_))
// Returns `true` if the subcommand depends on testing infrastructure.
pub fn needs_test(&self) -> bool {
matches!(
self,
Self::Test(_)
| Self::Jupyter(_)
| Self::Repl(_)
| Self::Bench(_)
| Self::Lsp
)
}
}

View file

@ -331,7 +331,6 @@ deno_core::extension!(
esm_entry_point = "ext:cli/99_main.js",
esm = [
dir "js",
"40_testing.js",
"99_main.js"
],
customizer = |ext: &mut deno_core::Extension| {

View file

@ -36,7 +36,7 @@
* }, { raw: true });
* ```
*/
{
(() => {
const internals = Deno[Deno.internal];
const core = internals.core;
@ -428,4 +428,4 @@
}
internals.enableJupyter = enableJupyter;
}
})();

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,2 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import "ext:cli/40_testing.js";
import "ext:cli/runtime/js/99_main.js";

View file

@ -639,9 +639,13 @@ impl CliMainWorkerFactory {
options,
);
if self.shared.subcommand.is_test_or_jupyter() {
if self.shared.subcommand.needs_test() {
worker.js_runtime.execute_script_static(
"40_jupyter.js",
"ext:cli/40_testing.js",
include_str!("js/40_testing.js"),
)?;
worker.js_runtime.execute_script_static(
"ext:cli/40_jupyter.js",
include_str!("js/40_jupyter.js"),
)?;
}

View file

@ -448,6 +448,11 @@ const finalDenoNs = {
resources: core.resources,
close: core.close,
...denoNs,
// Deno.test and Deno.bench are noops here, but kept for compatibility; so
// that they don't cause errors when used outside of `deno test`/`deno bench`
// contexts.
test: () => {},
bench: () => {},
};
const {