Skip to content

Commit

Permalink
Change RunnerTest to use V8Test
Browse files Browse the repository at this point in the history
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 <mlippautz@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1051098}
  • Loading branch information
jeisinger authored and Chromium LUCI CQ committed Sep 26, 2022
1 parent 5d7b9d8 commit c6fb876
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions gin/shell_runner_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit c6fb876

Please sign in to comment.