From 2e74f164b6dcf0ecbf8dd38fba9fae550d784bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 13 Dec 2020 19:45:53 +0100 Subject: refactor: deno_runtime crate (#8640) This commit moves Deno JS runtime, ops, permissions and inspector implementation to new "deno_runtime" crate located in "runtime/" directory. Details in "runtime/README.md". Co-authored-by: Ryan Dahl --- runtime/js.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 runtime/js.rs (limited to 'runtime/js.rs') diff --git a/runtime/js.rs b/runtime/js.rs new file mode 100644 index 000000000..efbc958c7 --- /dev/null +++ b/runtime/js.rs @@ -0,0 +1,31 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +use deno_core::Snapshot; + +pub static CLI_SNAPSHOT: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin")); + +pub fn deno_isolate_init() -> Snapshot { + debug!("Deno isolate init with snapshots."); + let data = CLI_SNAPSHOT; + Snapshot::Static(data) +} + +#[test] +fn cli_snapshot() { + let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions { + startup_snapshot: Some(deno_isolate_init()), + ..Default::default() + }); + js_runtime + .execute( + "", + r#" + if (!(bootstrap.mainRuntime && bootstrap.workerRuntime)) { + throw Error("bad"); + } + console.log("we have console.log!!!"); + "#, + ) + .unwrap(); +} -- cgit v1.2.3