From c6fb876d707baa77c541cdbe7bb3661db9beab07 Mon Sep 17 00:00:00 2001 From: Jochen Eisinger Date: Mon, 26 Sep 2022 07:56:19 +0000 Subject: [PATCH] Change RunnerTest to use V8Test V8 will not allow changing of flags by default, but V8Test configures it to allow for that. Without this, whatever test comes next will crash. Bug: 1367281 Change-Id: I6c7856123878f1a942f0e9398781d515f15b33f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3913566 Commit-Queue: Michael Lippautz Reviewed-by: Michael Lippautz Auto-Submit: Jochen Eisinger Cr-Commit-Position: refs/heads/main@{#1051098} --- gin/shell_runner_unittest.cc | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/gin/shell_runner_unittest.cc b/gin/shell_runner_unittest.cc index 655ab9caae8198..11996ef12e0100 100644 --- a/gin/shell_runner_unittest.cc +++ b/gin/shell_runner_unittest.cc @@ -4,43 +4,19 @@ #include "gin/shell_runner.h" -#include "base/compiler_specific.h" -#include "base/test/task_environment.h" -#include "base/threading/thread_task_runner_handle.h" -#include "gin/array_buffer.h" #include "gin/converter.h" #include "gin/public/isolate_holder.h" -#include "gin/v8_initializer.h" -#include "testing/gtest/include/gtest/gtest.h" - -#ifdef V8_USE_EXTERNAL_STARTUP_DATA -#include "gin/public/isolate_holder.h" -#endif - -using v8::Isolate; -using v8::Object; -using v8::Script; -using v8::String; +#include "gin/test/v8_test.h" namespace gin { -TEST(RunnerTest, Run) { - // V8 is generally multi threaded and may use tasks for arbitrary reasons, - // such as GC and off-thread compilation. - base::test::TaskEnvironment task_environment; - std::string source = "this.result = 'PASS';\n"; - -#ifdef V8_USE_EXTERNAL_STARTUP_DATA - gin::V8Initializer::LoadV8Snapshot(); -#endif +typedef V8Test RunnerTest; - gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, - gin::ArrayBufferAllocator::SharedInstance()); - gin::IsolateHolder instance(base::ThreadTaskRunnerHandle::Get(), - gin::IsolateHolder::IsolateType::kTest); +TEST_F(RunnerTest, Run) { + std::string source = "this.result = 'PASS';\n"; ShellRunnerDelegate delegate; - Isolate* isolate = instance.isolate(); + v8::Isolate* isolate = instance_->isolate(); ShellRunner runner(&delegate, isolate); Runner::Scope scope(&runner); runner.Run(source, "test_data.js");