Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: gin/test/file_runner.cc

Issue 594603003: Infrastructure for reading V8's initial snapshot from external files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gin/shell_runner_unittest.cc ('k') | gin/test/v8_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gin/test/file_runner.h" 5 #include "gin/test/file_runner.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "gin/array_buffer.h" 10 #include "gin/array_buffer.h"
11 #include "gin/converter.h" 11 #include "gin/converter.h"
12 #include "gin/modules/console.h" 12 #include "gin/modules/console.h"
13 #include "gin/modules/module_registry.h" 13 #include "gin/modules/module_registry.h"
14 #include "gin/public/context_holder.h" 14 #include "gin/public/context_holder.h"
15 #include "gin/public/isolate_holder.h" 15 #include "gin/public/isolate_holder.h"
16 #include "gin/test/file.h" 16 #include "gin/test/file.h"
17 #include "gin/test/gc.h" 17 #include "gin/test/gc.h"
18 #include "gin/test/gtest.h" 18 #include "gin/test/gtest.h"
19 #include "gin/try_catch.h" 19 #include "gin/try_catch.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
23 #include "gin/public/isolate_holder.h"
24 #endif
25
22 namespace gin { 26 namespace gin {
23 27
24 namespace { 28 namespace {
25 29
26 std::vector<base::FilePath> GetModuleSearchPaths() { 30 std::vector<base::FilePath> GetModuleSearchPaths() {
27 std::vector<base::FilePath> search_paths(2); 31 std::vector<base::FilePath> search_paths(2);
28 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]); 32 PathService::Get(base::DIR_SOURCE_ROOT, &search_paths[0]);
29 PathService::Get(base::DIR_EXE, &search_paths[1]); 33 PathService::Get(base::DIR_EXE, &search_paths[1]);
30 search_paths[1] = search_paths[1].AppendASCII("gen"); 34 search_paths[1] = search_paths[1].AppendASCII("gen");
31 return search_paths; 35 return search_paths;
(...skipping 19 matching lines...) Expand all
51 } 55 }
52 56
53 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate, 57 void RunTestFromFile(const base::FilePath& path, FileRunnerDelegate* delegate,
54 bool run_until_idle) { 58 bool run_until_idle) {
55 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName(); 59 ASSERT_TRUE(base::PathExists(path)) << path.LossyDisplayName();
56 std::string source; 60 std::string source;
57 ASSERT_TRUE(ReadFileToString(path, &source)); 61 ASSERT_TRUE(ReadFileToString(path, &source));
58 62
59 base::MessageLoop message_loop; 63 base::MessageLoop message_loop;
60 64
65 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
66 gin::IsolateHolder::LoadV8Snapshot();
67 #endif
68
61 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode, 69 gin::IsolateHolder::Initialize(gin::IsolateHolder::kStrictMode,
62 gin::ArrayBufferAllocator::SharedInstance()); 70 gin::ArrayBufferAllocator::SharedInstance());
63 gin::IsolateHolder instance; 71 gin::IsolateHolder instance;
64 gin::ShellRunner runner(delegate, instance.isolate()); 72 gin::ShellRunner runner(delegate, instance.isolate());
65 { 73 {
66 gin::Runner::Scope scope(&runner); 74 gin::Runner::Scope scope(&runner);
67 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); 75 v8::V8::SetCaptureStackTraceForUncaughtExceptions(true);
68 runner.Run(source, path.AsUTF8Unsafe()); 76 runner.Run(source, path.AsUTF8Unsafe());
69 77
70 if (run_until_idle) { 78 if (run_until_idle) {
71 message_loop.RunUntilIdle(); 79 message_loop.RunUntilIdle();
72 } else { 80 } else {
73 message_loop.Run(); 81 message_loop.Run();
74 } 82 }
75 83
76 v8::Handle<v8::Value> result = runner.global()->Get( 84 v8::Handle<v8::Value> result = runner.global()->Get(
77 StringToSymbol(runner.GetContextHolder()->isolate(), "result")); 85 StringToSymbol(runner.GetContextHolder()->isolate(), "result"));
78 EXPECT_EQ("PASS", V8ToString(result)); 86 EXPECT_EQ("PASS", V8ToString(result));
79 } 87 }
80 } 88 }
81 89
82 } // namespace gin 90 } // namespace gin
OLDNEW
« no previous file with comments | « gin/shell_runner_unittest.cc ('k') | gin/test/v8_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698