2021-01-11 12:13:41 -05:00
|
|
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
2020-12-13 13:45:53 -05:00
|
|
|
use deno_core::Snapshot;
|
2021-03-26 12:34:25 -04:00
|
|
|
use log::debug;
|
2020-12-13 13:45:53 -05:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2021-02-01 10:55:23 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[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(
|
|
|
|
"<anon>",
|
|
|
|
r#"
|
2020-12-13 13:45:53 -05:00
|
|
|
if (!(bootstrap.mainRuntime && bootstrap.workerRuntime)) {
|
|
|
|
throw Error("bad");
|
|
|
|
}
|
|
|
|
console.log("we have console.log!!!");
|
|
|
|
"#,
|
2021-02-01 10:55:23 -05:00
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
}
|
2020-12-13 13:45:53 -05:00
|
|
|
}
|