diff --git a/test/cctest/node_test_fixture.cc b/test/cctest/node_test_fixture.cc index f13481824734fb..1a50e58dd9e8fa 100644 --- a/test/cctest/node_test_fixture.cc +++ b/test/cctest/node_test_fixture.cc @@ -4,3 +4,4 @@ ArrayBufferUniquePtr NodeTestFixture::allocator{nullptr, nullptr}; uv_loop_t NodeTestFixture::current_loop; NodePlatformUniquePtr NodeTestFixture::platform; TracingAgentUniquePtr NodeTestFixture::tracing_agent; +bool NodeTestFixture::node_initialized = false; diff --git a/test/cctest/node_test_fixture.h b/test/cctest/node_test_fixture.h index f7ecb9cdea744e..02c1164691b138 100644 --- a/test/cctest/node_test_fixture.h +++ b/test/cctest/node_test_fixture.h @@ -64,9 +64,19 @@ class NodeTestFixture : public ::testing::Test { static TracingAgentUniquePtr tracing_agent; static NodePlatformUniquePtr platform; static uv_loop_t current_loop; + static bool node_initialized; v8::Isolate* isolate_; static void SetUpTestCase() { + if (!node_initialized) { + node_initialized = true; + int argc = 1; + const char* argv0 = "cctest"; + int exec_argc; + const char** exec_argv; + node::Init(&argc, &argv0, &exec_argc, &exec_argv); + } + tracing_agent.reset(new node::tracing::Agent()); node::tracing::TraceEventHelper::SetAgent(tracing_agent.get()); CHECK_EQ(0, uv_loop_init(¤t_loop)); @@ -89,9 +99,11 @@ class NodeTestFixture : public ::testing::Test { &node::FreeArrayBufferAllocator); isolate_ = NewIsolate(allocator.get(), ¤t_loop); CHECK_NE(isolate_, nullptr); + isolate_->Enter(); } void TearDown() override { + isolate_->Exit(); isolate_->Dispose(); platform->UnregisterIsolate(isolate_); isolate_ = nullptr; @@ -118,6 +130,8 @@ class EnvironmentTestFixture : public NodeTestFixture { 1, *argv, argv.nr_args(), *argv); CHECK_NE(nullptr, environment_); + // TODO(addaleax): Make this a public API. + CHECK(!RunBootstrapping(environment_).IsEmpty()); } ~Env() {