diff --git a/test/cctest/cctest.cc b/test/cctest/cctest.cc index 865bc6d22a..b1cf5abb4e 100644 --- a/test/cctest/cctest.cc +++ b/test/cctest/cctest.cc @@ -199,6 +199,7 @@ int main(int argc, char* argv[]) { } if (print_run_count && tests_run != 1) printf("Ran %i tests.\n", tests_run); + CcTest::TearDown(); if (!disable_automatic_dispose_) v8::V8::Dispose(); return 0; } diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index 6d2c552ac6..6c67dd52ec 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -130,6 +130,11 @@ class CcTest { CcTestExtensionFlags extensions, v8::Isolate* isolate = CcTest::isolate()); + static void TearDown() { + // TODO(svenpanne) Enable this when our cctests are fixed. + // if (isolate_ != NULL) isolate_->Dispose(); + } + private: friend int main(int argc, char** argv); TestFunction* callback_; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 561fd4e397..48730001ae 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -462,13 +462,13 @@ static uint16_t* AsciiToTwoByteString(const char* source) { class TestResource: public String::ExternalStringResource { public: - explicit TestResource(uint16_t* data, int* counter = NULL) - : data_(data), length_(0), counter_(counter) { + TestResource(uint16_t* data, int* counter = NULL, bool owning_data = true) + : data_(data), length_(0), counter_(counter), owning_data_(owning_data) { while (data[length_]) ++length_; } ~TestResource() { - i::DeleteArray(data_); + if (owning_data_) i::DeleteArray(data_); if (counter_ != NULL) ++*counter_; } @@ -479,10 +479,12 @@ class TestResource: public String::ExternalStringResource { size_t length() const { return length_; } + private: uint16_t* data_; size_t length_; int* counter_; + bool owning_data_; }; @@ -15218,13 +15220,10 @@ TEST(CompileExternalTwoByteSource) { // Compile the sources as external two byte strings. for (int i = 0; ascii_sources[i] != NULL; i++) { uint16_t* two_byte_string = AsciiToTwoByteString(ascii_sources[i]); - UC16VectorResource uc16_resource( - i::Vector(two_byte_string, - i::StrLength(ascii_sources[i]))); + TestResource* uc16_resource = new TestResource(two_byte_string); v8::Local source = - v8::String::NewExternal(context->GetIsolate(), &uc16_resource); + v8::String::NewExternal(context->GetIsolate(), uc16_resource); v8::Script::Compile(source); - i::DeleteArray(two_byte_string); } } @@ -17871,12 +17870,12 @@ TEST(VisitExternalStrings) { resource[0] = new TestResource(two_byte_string); v8::Local string0 = v8::String::NewExternal(env->GetIsolate(), resource[0]); - resource[1] = new TestResource(two_byte_string); + resource[1] = new TestResource(two_byte_string, NULL, false); v8::Local string1 = v8::String::NewExternal(env->GetIsolate(), resource[1]); // Externalized symbol. - resource[2] = new TestResource(two_byte_string); + resource[2] = new TestResource(two_byte_string, NULL, false); v8::Local string2 = v8::String::NewFromUtf8( env->GetIsolate(), string, v8::String::kInternalizedString); CHECK(string2->MakeExternal(resource[2]));