Author: [email protected]
Date: Wed Jun  3 05:09:52 2009
New Revision: 2095

Modified:
    branches/bleeding_edge/test/cctest/test-api.cc

Log:
Fix flakyness in tests: make sure to garbage collect temporary test
external strings so that they are not disposed when running other
tests that rely on only one external string being disposed during its
run.

TBR=kasperl
Review URL: http://codereview.chromium.org/118158

Modified: branches/bleeding_edge/test/cctest/test-api.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-api.cc      (original)
+++ branches/bleeding_edge/test/cctest/test-api.cc      Wed Jun  3 05:09:52 2009
@@ -538,29 +538,36 @@


  THREADED_TEST(UsingExternalString) {
-  v8::HandleScope scope;
-  uint16_t* two_byte_string = AsciiToTwoByteString("test string");
-  Local<String> string = String::NewExternal(new  
TestResource(two_byte_string));
-  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
-  // Trigger GCs so that the newly allocated string moves to old gen.
-  i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in survivor space now
-  i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in old gen now
-  i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
-  CHECK(isymbol->IsSymbol());
+  {
+    v8::HandleScope scope;
+    uint16_t* two_byte_string = AsciiToTwoByteString("test string");
+    Local<String> string =
+        String::NewExternal(new TestResource(two_byte_string));
+    i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
+    // Trigger GCs so that the newly allocated string moves to old gen.
+    i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in survivor space now
+    i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in old gen now
+    i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
+    CHECK(isymbol->IsSymbol());
+  }
+  i::Heap::CollectAllGarbage();
  }


  THREADED_TEST(UsingExternalAsciiString) {
-  v8::HandleScope scope;
-  const char* one_byte_string = "test string";
-  Local<String> string = String::NewExternal(
-      new TestAsciiResource(i::StrDup(one_byte_string)));
-  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
-  // Trigger GCs so that the newly allocated string moves to old gen.
-  i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in survivor space now
-  i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in old gen now
-  i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
-  CHECK(isymbol->IsSymbol());
+  {
+    v8::HandleScope scope;
+    const char* one_byte_string = "test string";
+    Local<String> string = String::NewExternal(
+        new TestAsciiResource(i::StrDup(one_byte_string)));
+    i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
+    // Trigger GCs so that the newly allocated string moves to old gen.
+    i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in survivor space now
+    i::Heap::CollectGarbage(0, i::NEW_SPACE);  // in old gen now
+    i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
+    CHECK(isymbol->IsSymbol());
+  }
+  i::Heap::CollectAllGarbage();
  }



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to