From 570269b73de713afcff712977d11a3910ed849ad Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Mon, 26 Nov 2018 14:20:16 -0500 Subject: [PATCH] Don't use snapshot for src/isolate.rs tests. --- libdeno/api.cc | 5 +++++ src/isolate.rs | 27 +++++---------------------- 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/libdeno/api.cc b/libdeno/api.cc index 6ee2c934f4..c059bb534a 100644 --- a/libdeno/api.cc +++ b/libdeno/api.cc @@ -36,6 +36,11 @@ Deno* deno_new(deno_buf snapshot, deno_buf shared, deno_recv_cb cb) { v8::MaybeLocal(), v8::DeserializeInternalFieldsCallback( deno::DeserializeInternalFields, nullptr)); + if (!snapshot.data_ptr) { + // If no snapshot is provided, we initialize the context with empty + // main source code and source maps. + deno::InitializeContext(isolate, context, "", "", ""); + } d->context_.Reset(isolate, context); } diff --git a/src/isolate.rs b/src/isolate.rs index abc5ded4d3..acd40e5d84 100644 --- a/src/isolate.rs +++ b/src/isolate.rs @@ -393,19 +393,12 @@ fn recv_deadline( mod tests { use super::*; use futures; - use snapshot; #[test] fn test_dispatch_sync() { let argv = vec![String::from("./deno"), String::from("hello.js")]; let (flags, rest_argv, _) = flags::set_flags(argv).unwrap(); - // TODO Don't use deno_snapshot for these tests. - let mut isolate = Isolate::new( - unsafe { snapshot::deno_snapshot.clone() }, - flags, - rest_argv, - dispatch_sync, - ); + let mut isolate = Isolate::new(empty(), flags, rest_argv, dispatch_sync); tokio_util::init(|| { isolate .execute( @@ -445,13 +438,8 @@ mod tests { fn test_metrics_sync() { let argv = vec![String::from("./deno"), String::from("hello.js")]; let (flags, rest_argv, _) = flags::set_flags(argv).unwrap(); - // TODO Don't use deno_snapshot for these tests. - let mut isolate = Isolate::new( - unsafe { snapshot::deno_snapshot.clone() }, - flags, - rest_argv, - metrics_dispatch_sync, - ); + let mut isolate = + Isolate::new(empty(), flags, rest_argv, metrics_dispatch_sync); tokio_util::init(|| { // Verify that metrics have been properly initialized. { @@ -486,13 +474,8 @@ mod tests { fn test_metrics_async() { let argv = vec![String::from("./deno"), String::from("hello.js")]; let (flags, rest_argv, _) = flags::set_flags(argv).unwrap(); - // TODO Don't use deno_snapshot for these tests. - let mut isolate = Isolate::new( - unsafe { snapshot::deno_snapshot.clone() }, - flags, - rest_argv, - metrics_dispatch_async, - ); + let mut isolate = + Isolate::new(empty(), flags, rest_argv, metrics_dispatch_async); tokio_util::init(|| { // Verify that metrics have been properly initialized. {