Disable three debug tests that failed because they rely on wrong for-in order.
authorfeng@chromium.org <feng@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Sep 2008 00:04:37 +0000 (00:04 +0000)
committerfeng@chromium.org <feng@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 5 Sep 2008 00:04:37 +0000 (00:04 +0000)
Added a DISABLED_TEST macro to cctest.h, and cleanup cctest.cc a bit.

Review URL: http://codereview.chromium.org/456

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@148 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/cctest/cctest.cc
test/cctest/cctest.h
test/cctest/test-debug.cc

index eef295f..4e5c627 100644 (file)
@@ -35,7 +35,8 @@
 CcTest* CcTest::last_ = NULL;
 
 
-CcTest::CcTest(TestFunction* callback, const char* file, const char* name)
+CcTest::CcTest(TestFunction* callback, const char* file,
+               const char* name, bool enabled)
     : callback_(callback), name_(name), prev_(last_) {
   // Find the base name of this test (const_cast required on Windows).
   char *basename = strrchr(const_cast<char *>(file), '/');
@@ -52,6 +53,7 @@ CcTest::CcTest(TestFunction* callback, const char* file, const char* name)
   if (extension) *extension = 0;
   // Install this test in the list of tests
   file_ = basename;
+  enabled_ = enabled;
   prev_ = last_;
   last_ = this;
 }
@@ -64,30 +66,6 @@ static void PrintTestList(CcTest* current) {
 }
 
 
-static int RunMatchingTests(CcTest* current, char* file_or_name) {
-  if (current == NULL) return 0;
-  int run_count = 0;
-  if (strcmp(current->file(), file_or_name) == 0
-      || strcmp(current->name(), file_or_name) == 0) {
-    current->Run();
-    run_count++;
-  }
-  return run_count + RunMatchingTests(current->prev(), file_or_name);
-}
-
-
-static int RunMatchingTests(CcTest* current, char* file, char* name) {
-  if (current == NULL) return 0;
-  int run_count = 0;
-  if (strcmp(current->file(), file) == 0
-      && strcmp(current->name(), name) == 0) {
-    current->Run();
-    run_count++;
-  }
-  return run_count + RunMatchingTests(current->prev(), file, name);
-}
-
-
 int main(int argc, char* argv[]) {
   v8::internal::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
   int tests_run = 0;
@@ -97,6 +75,7 @@ int main(int argc, char* argv[]) {
     if (strcmp(arg, "--list") == 0) {
       PrintTestList(CcTest::last());
       print_run_count = false;
+
     } else {
       char* arg_copy = strdup(arg);
       char* testname = strchr(arg_copy, '/');
@@ -104,10 +83,32 @@ int main(int argc, char* argv[]) {
         // Split the string in two by nulling the slash and then run
         // exact matches.
         *testname = 0;
-        tests_run += RunMatchingTests(CcTest::last(), arg_copy, testname + 1);
+        char* file = arg_copy;
+        char* name = testname + 1;
+        CcTest* test = CcTest::last();
+        while (test != NULL) {
+          if (test->enabled()
+              && strcmp(test->file(), file) == 0
+              && strcmp(test->name(), name) == 0) {
+            test->Run();
+            tests_run++;
+          }
+          test = test->prev();
+        }
+
       } else {
         // Run all tests with the specified file or test name.
-        tests_run += RunMatchingTests(CcTest::last(), arg_copy);
+        char* file_or_name = arg_copy;
+        CcTest* test = CcTest::last();
+        while (test != NULL) {
+          if (test->enabled()
+              && (strcmp(test->file(), file_or_name) == 0
+                  || strcmp(test->name(), file_or_name) == 0)) {
+            test->Run();
+            tests_run++;
+          }
+          test = test->prev();
+        }
       }
       free(arg_copy);
     }
index e3de881..6ce4248 100644 (file)
 #ifndef TEST
 #define TEST(Name)                                                   \
   static void Test##Name();                                          \
-  CcTest register_test_##Name(Test##Name, __FILE__, #Name);          \
+  CcTest register_test_##Name(Test##Name, __FILE__, #Name, true);    \
+  static void Test##Name()
+#endif
+
+#ifndef DISABLED_TEST
+#define DISABLED_TEST(Name)                                          \
+  static void Test##Name();                                          \
+  CcTest register_test_##Name(Test##Name, __FILE__, #Name, false);   \
   static void Test##Name()
 #endif
 
 class CcTest {
  public:
   typedef void (TestFunction)();
-  CcTest(TestFunction* callback, const char* file, const char* name);
+  CcTest(TestFunction* callback, const char* file, const char* name,
+         bool enabled);
   void Run() { callback_(); }
   static int test_count();
   static CcTest* last() { return last_; }
   CcTest* prev() { return prev_; }
   const char* file() { return file_; }
   const char* name() { return name_; }
+  bool enabled() { return enabled_; }
  private:
   TestFunction* callback_;
   const char* file_;
   const char* name_;
+  bool enabled_;
   static CcTest* last_;
   CcTest* prev_;
 };
index 3b1ffa7..34916cc 100644 (file)
@@ -2856,7 +2856,7 @@ void MessageQueueDebuggerThread::Run() {
 MessageQueueDebuggerThread message_queue_debugger_thread;
 
 // This thread runs the v8 engine.
-TEST(MessageQueues) {
+DISABLED_TEST(MessageQueues) {
   // Create a V8 environment
   v8::HandleScope scope;
   DebugLocalContext env;
@@ -2961,7 +2961,7 @@ void DebuggerThread::Run() {
 DebuggerThread debugger_thread;
 V8Thread v8_thread;
 
-TEST(ThreadedDebugging) {
+DISABLED_TEST(ThreadedDebugging) {
   // Create a V8 environment
   threaded_debugging_barriers.Initialize();
 
@@ -3120,7 +3120,7 @@ void BreakpointsDebuggerThread::Run() {
 BreakpointsDebuggerThread breakpoints_debugger_thread;
 BreakpointsV8Thread breakpoints_v8_thread;
 
-TEST(RecursiveBreakpoints) {
+DISABLED_TEST(RecursiveBreakpoints) {
   // Create a V8 environment
   Barriers stack_allocated_breakpoints_barriers;
   stack_allocated_breakpoints_barriers.Initialize();