2023-01-13 02:51:32 -05:00
|
|
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2022-11-21 08:36:26 -05:00
|
|
|
use deno_core::Snapshot;
|
2023-03-08 10:44:04 -05:00
|
|
|
use log::debug;
|
2022-11-21 08:36:26 -05:00
|
|
|
|
2023-03-16 23:19:46 -04:00
|
|
|
static CLI_SNAPSHOT: &[u8] =
|
|
|
|
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
|
2022-11-21 08:36:26 -05:00
|
|
|
|
|
|
|
pub fn deno_isolate_init() -> Snapshot {
|
2023-03-08 10:44:04 -05:00
|
|
|
debug!("Deno isolate init with snapshots.");
|
2023-03-16 23:19:46 -04:00
|
|
|
Snapshot::Static(CLI_SNAPSHOT)
|
2022-11-21 08:36:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn runtime_snapshot() {
|
|
|
|
let mut js_runtime = deno_core::JsRuntime::new(deno_core::RuntimeOptions {
|
|
|
|
startup_snapshot: Some(deno_isolate_init()),
|
|
|
|
..Default::default()
|
|
|
|
});
|
|
|
|
js_runtime
|
2023-04-04 08:46:31 -04:00
|
|
|
.execute_script_static(
|
2022-11-21 08:36:26 -05:00
|
|
|
"<anon>",
|
|
|
|
r#"
|
|
|
|
if (!(bootstrap.mainRuntime && bootstrap.workerRuntime)) {
|
|
|
|
throw Error("bad");
|
|
|
|
}
|
|
|
|
console.log("we have console.log!!!");
|
|
|
|
"#,
|
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|