From 2561484dcb17035f847705940cb61634493196c8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 27 Feb 2020 14:20:00 -0800 Subject: [PATCH] test: re-enable cctest that was commented out Refs: https://github.com/nodejs/node/pull/31910 PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- test/cctest/test_environment.cc | 39 ++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/test/cctest/test_environment.cc b/test/cctest/test_environment.cc index 15d9b45d490e8f..4d8237f103a07e 100644 --- a/test/cctest/test_environment.cc +++ b/test/cctest/test_environment.cc @@ -32,24 +32,27 @@ class EnvironmentTest : public EnvironmentTestFixture { } }; -// TODO(codebytere): re-enable this test. -// TEST_F(EnvironmentTest, PreExeuctionPreparation) { -// const v8::HandleScope handle_scope(isolate_); -// const Argv argv; -// Env env {handle_scope, argv}; - -// v8::Local context = isolate_->GetCurrentContext(); - -// const char* run_script = "process.argv0"; -// v8::Local script = v8::Script::Compile( -// context, -// v8::String::NewFromOneByte(isolate_, -// reinterpret_cast(run_script), -// v8::NewStringType::kNormal).ToLocalChecked()) -// .ToLocalChecked(); -// v8::Local result = script->Run(context).ToLocalChecked(); -// CHECK(result->IsString()); -// } +TEST_F(EnvironmentTest, PreExecutionPreparation) { + const v8::HandleScope handle_scope(isolate_); + const Argv argv; + Env env {handle_scope, argv}; + + node::LoadEnvironment(*env, [&](const node::StartExecutionCallbackInfo& info) + -> v8::MaybeLocal { + return v8::Null(isolate_); + }); + + v8::Local context = isolate_->GetCurrentContext(); + const char* run_script = "process.argv0"; + v8::Local script = v8::Script::Compile( + context, + v8::String::NewFromOneByte(isolate_, + reinterpret_cast(run_script), + v8::NewStringType::kNormal).ToLocalChecked()) + .ToLocalChecked(); + v8::Local result = script->Run(context).ToLocalChecked(); + CHECK(result->IsString()); +} TEST_F(EnvironmentTest, LoadEnvironmentWithCallback) { const v8::HandleScope handle_scope(isolate_);