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

Side by Side Diff: test/cctest/cctest.cc

Issue 23929006: remove remaining uses of default isolate in tests (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix serializer tests Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-api.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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 13 matching lines...) Expand all
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <v8.h> 28 #include <v8.h>
29 #include "cctest.h" 29 #include "cctest.h"
30 #include "debug.h" 30 #include "debug.h"
31 31
32 enum InitializationState {kUnset, kUnintialized, kInitialized}; 32 enum InitializationState {kUnset, kUnintialized, kInitialized};
33 static InitializationState initialization_state_ = kUnset; 33 static InitializationState initialization_state_ = kUnset;
34 static bool disable_automatic_dispose_ = false;
34 35
35 CcTest* CcTest::last_ = NULL; 36 CcTest* CcTest::last_ = NULL;
36 bool CcTest::initialize_called_ = false; 37 bool CcTest::initialize_called_ = false;
37 bool CcTest::isolate_used_ = false; 38 bool CcTest::isolate_used_ = false;
38 v8::Isolate* CcTest::isolate_ = NULL; 39 v8::Isolate* CcTest::isolate_ = NULL;
39 40
40 41
41 CcTest::CcTest(TestFunction* callback, const char* file, const char* name, 42 CcTest::CcTest(TestFunction* callback, const char* file, const char* name,
42 const char* dependency, bool enabled, bool initialize) 43 const char* dependency, bool enabled, bool initialize)
43 : callback_(callback), name_(name), dependency_(dependency), 44 : callback_(callback), name_(name), dependency_(dependency),
(...skipping 15 matching lines...) Expand all
59 file_ = basename; 60 file_ = basename;
60 prev_ = last_; 61 prev_ = last_;
61 last_ = this; 62 last_ = this;
62 } 63 }
63 64
64 65
65 void CcTest::Run() { 66 void CcTest::Run() {
66 if (!initialize_) { 67 if (!initialize_) {
67 CHECK(initialization_state_ != kInitialized); 68 CHECK(initialization_state_ != kInitialized);
68 initialization_state_ = kUnintialized; 69 initialization_state_ = kUnintialized;
69 // TODO(dcarney): Remove this when default isolate is gone. 70 CHECK(CcTest::isolate_ == NULL);
70 if (isolate_ == NULL) {
71 isolate_ = v8::Isolate::GetCurrent();
72 }
73 } else { 71 } else {
74 CHECK(initialization_state_ != kUnintialized); 72 CHECK(initialization_state_ != kUnintialized);
75 initialization_state_ = kInitialized; 73 initialization_state_ = kInitialized;
76 i::Isolate::SetCrashIfDefaultIsolateInitialized();
77 if (isolate_ == NULL) { 74 if (isolate_ == NULL) {
78 isolate_ = v8::Isolate::New(); 75 isolate_ = v8::Isolate::New();
79 } 76 }
80 isolate_->Enter(); 77 isolate_->Enter();
81 } 78 }
82 callback_(); 79 callback_();
83 if (initialize_) { 80 if (initialize_) {
84 isolate_->Exit(); 81 isolate_->Exit();
85 } 82 }
86 } 83 }
87 84
88 85
89 v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extensions, 86 v8::Local<v8::Context> CcTest::NewContext(CcTestExtensionFlags extensions,
90 v8::Isolate* isolate) { 87 v8::Isolate* isolate) {
91 const char* extension_names[kMaxExtensions]; 88 const char* extension_names[kMaxExtensions];
92 int extension_count = 0; 89 int extension_count = 0;
93 #define CHECK_EXTENSION_FLAG(Name, Id) \ 90 #define CHECK_EXTENSION_FLAG(Name, Id) \
94 if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id; 91 if (extensions.Contains(Name##_ID)) extension_names[extension_count++] = Id;
95 EXTENSION_LIST(CHECK_EXTENSION_FLAG) 92 EXTENSION_LIST(CHECK_EXTENSION_FLAG)
96 #undef CHECK_EXTENSION_FLAG 93 #undef CHECK_EXTENSION_FLAG
97 v8::ExtensionConfiguration config(extension_count, extension_names); 94 v8::ExtensionConfiguration config(extension_count, extension_names);
98 v8::Local<v8::Context> context = v8::Context::New(isolate, &config); 95 v8::Local<v8::Context> context = v8::Context::New(isolate, &config);
99 CHECK(!context.IsEmpty()); 96 CHECK(!context.IsEmpty());
100 return context; 97 return context;
101 } 98 }
102 99
103 100
101 void CcTest::DisableAutomaticDispose() {
102 CHECK_EQ(kUnintialized, initialization_state_);
103 disable_automatic_dispose_ = true;
104 }
105
106
104 static void PrintTestList(CcTest* current) { 107 static void PrintTestList(CcTest* current) {
105 if (current == NULL) return; 108 if (current == NULL) return;
106 PrintTestList(current->prev()); 109 PrintTestList(current->prev());
107 if (current->dependency() != NULL) { 110 if (current->dependency() != NULL) {
108 printf("%s/%s<%s\n", 111 printf("%s/%s<%s\n",
109 current->file(), current->name(), current->dependency()); 112 current->file(), current->name(), current->dependency());
110 } else { 113 } else {
111 printf("%s/%s<\n", current->file(), current->name()); 114 printf("%s/%s<\n", current->file(), current->name());
112 } 115 }
113 } 116 }
(...skipping 10 matching lines...) Expand all
124 127
125 static void SuggestTestHarness(int tests) { 128 static void SuggestTestHarness(int tests) {
126 if (tests == 0) return; 129 if (tests == 0) return;
127 printf("Running multiple tests in sequence is deprecated and may cause " 130 printf("Running multiple tests in sequence is deprecated and may cause "
128 "bogus failure. Consider using tools/run-tests.py instead.\n"); 131 "bogus failure. Consider using tools/run-tests.py instead.\n");
129 } 132 }
130 133
131 134
132 int main(int argc, char* argv[]) { 135 int main(int argc, char* argv[]) {
133 v8::V8::InitializeICU(); 136 v8::V8::InitializeICU();
137 i::Isolate::SetCrashIfDefaultIsolateInitialized();
134 138
135 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 139 v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
136 140
137 CcTestArrayBufferAllocator array_buffer_allocator; 141 CcTestArrayBufferAllocator array_buffer_allocator;
138 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); 142 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
139 143
140 int tests_run = 0; 144 int tests_run = 0;
141 bool print_run_count = true; 145 bool print_run_count = true;
142 for (int i = 1; i < argc; i++) { 146 for (int i = 1; i < argc; i++) {
143 char* arg = argv[i]; 147 char* arg = argv[i];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 test->Run(); 181 test->Run();
178 } 182 }
179 test = test->prev(); 183 test = test->prev();
180 } 184 }
181 } 185 }
182 v8::internal::DeleteArray<char>(arg_copy); 186 v8::internal::DeleteArray<char>(arg_copy);
183 } 187 }
184 } 188 }
185 if (print_run_count && tests_run != 1) 189 if (print_run_count && tests_run != 1)
186 printf("Ran %i tests.\n", tests_run); 190 printf("Ran %i tests.\n", tests_run);
187 v8::V8::Dispose(); 191 if (!disable_automatic_dispose_) v8::V8::Dispose();
188 return 0; 192 return 0;
189 } 193 }
190 194
191 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL; 195 RegisterThreadedTest *RegisterThreadedTest::first_ = NULL;
192 int RegisterThreadedTest::count_ = 0; 196 int RegisterThreadedTest::count_ = 0;
OLDNEW
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698