Reland "Refactoring: Make gtest testsuite the default."
authormachenbach@chromium.org <machenbach@chromium.org>
Tue, 2 Sep 2014 09:21:03 +0000 (09:21 +0000)
committermachenbach@chromium.org <machenbach@chromium.org>
Tue, 2 Sep 2014 09:21:03 +0000 (09:21 +0000)
BUG=v8:3489
TBR=bmeurer@chromium.org
LOG=n

Review URL: https://codereview.chromium.org/533603002

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

test/base-unittests/testcfg.py [deleted file]
test/compiler-unittests/testcfg.py [deleted file]
test/heap-unittests/testcfg.py [deleted file]
test/libplatform-unittests/testcfg.py [deleted file]
tools/testrunner/local/testsuite.py
tools/testrunner/local/utils.py

diff --git a/test/base-unittests/testcfg.py b/test/base-unittests/testcfg.py
deleted file mode 100644 (file)
index b6ae5b2..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import shutil
-
-from testrunner.local import commands
-from testrunner.local import testsuite
-from testrunner.local import utils
-from testrunner.objects import testcase
-
-
-class BaseUnitTestsSuite(testsuite.TestSuite):
-  def __init__(self, name, root):
-    super(BaseUnitTestsSuite, self).__init__(name, root)
-
-  def ListTests(self, context):
-    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
-    if utils.IsWindows():
-      shell += ".exe"
-    output = commands.Execute(context.command_prefix +
-                              [shell, "--gtest_list_tests"] +
-                              context.extra_flags)
-    if output.exit_code != 0:
-      print output.stdout
-      print output.stderr
-      return []
-    tests = []
-    test_case = ''
-    for line in output.stdout.splitlines():
-      test_desc = line.strip().split()[0]
-      if test_desc.endswith('.'):
-        test_case = test_desc
-      elif test_case and test_desc:
-        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
-        tests.append(test)
-    tests.sort()
-    return tests
-
-  def GetFlagsForTestCase(self, testcase, context):
-    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
-            ["--gtest_random_seed=%s" % context.random_seed] +
-            ["--gtest_print_time=0"] +
-            context.mode_flags)
-
-  def shell(self):
-    return "base-unittests"
-
-
-def GetSuite(name, root):
-  return BaseUnitTestsSuite(name, root)
diff --git a/test/compiler-unittests/testcfg.py b/test/compiler-unittests/testcfg.py
deleted file mode 100644 (file)
index b067aee..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import shutil
-
-from testrunner.local import commands
-from testrunner.local import testsuite
-from testrunner.local import utils
-from testrunner.objects import testcase
-
-
-class CompilerUnitTestsSuite(testsuite.TestSuite):
-  def __init__(self, name, root):
-    super(CompilerUnitTestsSuite, self).__init__(name, root)
-
-  def ListTests(self, context):
-    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
-    if utils.IsWindows():
-      shell += ".exe"
-    output = commands.Execute(context.command_prefix +
-                              [shell, "--gtest_list_tests"] +
-                              context.extra_flags)
-    if output.exit_code != 0:
-      print output.stdout
-      print output.stderr
-      return []
-    tests = []
-    test_case = ''
-    for line in output.stdout.splitlines():
-      test_desc = line.strip().split()[0]
-      if test_desc.endswith('.'):
-        test_case = test_desc
-      elif test_case and test_desc:
-        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
-        tests.append(test)
-    tests.sort()
-    return tests
-
-  def GetFlagsForTestCase(self, testcase, context):
-    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
-            ["--gtest_random_seed=%s" % context.random_seed] +
-            ["--gtest_print_time=0"] +
-            context.mode_flags)
-
-  def shell(self):
-    return "compiler-unittests"
-
-
-def GetSuite(name, root):
-  return CompilerUnitTestsSuite(name, root)
diff --git a/test/heap-unittests/testcfg.py b/test/heap-unittests/testcfg.py
deleted file mode 100644 (file)
index ffa4b59..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import shutil
-
-from testrunner.local import commands
-from testrunner.local import testsuite
-from testrunner.local import utils
-from testrunner.objects import testcase
-
-
-class HeapUnitTestsSuite(testsuite.TestSuite):
-  def __init__(self, name, root):
-    super(HeapUnitTestsSuite, self).__init__(name, root)
-
-  def ListTests(self, context):
-    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
-    if utils.IsWindows():
-      shell += ".exe"
-    output = commands.Execute(context.command_prefix +
-                              [shell, "--gtest_list_tests"] +
-                              context.extra_flags)
-    if output.exit_code != 0:
-      print output.stdout
-      print output.stderr
-      return []
-    tests = []
-    test_case = ''
-    for line in output.stdout.splitlines():
-      test_desc = line.strip().split()[0]
-      if test_desc.endswith('.'):
-        test_case = test_desc
-      elif test_case and test_desc:
-        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
-        tests.append(test)
-    tests.sort()
-    return tests
-
-  def GetFlagsForTestCase(self, testcase, context):
-    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
-            ["--gtest_random_seed=%s" % context.random_seed] +
-            ["--gtest_print_time=0"] +
-            context.mode_flags)
-
-  def shell(self):
-    return "heap-unittests"
-
-
-def GetSuite(name, root):
-  return HeapUnitTestsSuite(name, root)
diff --git a/test/libplatform-unittests/testcfg.py b/test/libplatform-unittests/testcfg.py
deleted file mode 100644 (file)
index 7370b5a..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2014 the V8 project authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import shutil
-
-from testrunner.local import commands
-from testrunner.local import testsuite
-from testrunner.local import utils
-from testrunner.objects import testcase
-
-
-class LibplatformUnitTestsSuite(testsuite.TestSuite):
-  def __init__(self, name, root):
-    super(LibplatformUnitTestsSuite, self).__init__(name, root)
-
-  def ListTests(self, context):
-    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
-    if utils.IsWindows():
-      shell += ".exe"
-    output = commands.Execute(context.command_prefix +
-                              [shell, "--gtest_list_tests"] +
-                              context.extra_flags)
-    if output.exit_code != 0:
-      print output.stdout
-      print output.stderr
-      return []
-    tests = []
-    test_case = ''
-    for line in output.stdout.splitlines():
-      test_desc = line.strip().split()[0]
-      if test_desc.endswith('.'):
-        test_case = test_desc
-      elif test_case and test_desc:
-        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
-        tests.append(test)
-    tests.sort()
-    return tests
-
-  def GetFlagsForTestCase(self, testcase, context):
-    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
-            ["--gtest_random_seed=%s" % context.random_seed] +
-            ["--gtest_print_time=0"] +
-            context.mode_flags)
-
-  def shell(self):
-    return "libplatform-unittests"
-
-
-def GetSuite(name, root):
-  return LibplatformUnitTestsSuite(name, root)
index 0fd3f3a..e831c48 100644 (file)
@@ -41,11 +41,13 @@ class TestSuite(object):
     try:
       (f, pathname, description) = imp.find_module("testcfg", [root])
       module = imp.load_module("testcfg", f, pathname, description)
-      suite = module.GetSuite(name, root)
+      return module.GetSuite(name, root)
+    except:
+      # Use default if no testcfg is present.
+      return GoogleTestSuite(name, root)
     finally:
       if f:
         f.close()
-    return suite
 
   def __init__(self, name, root):
     self.name = name  # string
@@ -214,3 +216,40 @@ class TestSuite(object):
     for t in self.tests:
       self.total_duration += t.duration
     return self.total_duration
+
+
+class GoogleTestSuite(TestSuite):
+  def __init__(self, name, root):
+    super(GoogleTestSuite, self).__init__(name, root)
+
+  def ListTests(self, context):
+    shell = os.path.abspath(os.path.join(context.shell_dir, self.shell()))
+    if utils.IsWindows():
+      shell += ".exe"
+    output = commands.Execute(context.command_prefix +
+                              [shell, "--gtest_list_tests"] +
+                              context.extra_flags)
+    if output.exit_code != 0:
+      print output.stdout
+      print output.stderr
+      return []
+    tests = []
+    test_case = ''
+    for line in output.stdout.splitlines():
+      test_desc = line.strip().split()[0]
+      if test_desc.endswith('.'):
+        test_case = test_desc
+      elif test_case and test_desc:
+        test = testcase.TestCase(self, test_case + test_desc, dependency=None)
+        tests.append(test)
+    tests.sort()
+    return tests
+
+  def GetFlagsForTestCase(self, testcase, context):
+    return (testcase.flags + ["--gtest_filter=" + testcase.path] +
+            ["--gtest_random_seed=%s" % context.random_seed] +
+            ["--gtest_print_time=0"] +
+            context.mode_flags)
+
+  def shell(self):
+    return self.name
index 707fa24..7bc21b1 100644 (file)
@@ -36,9 +36,7 @@ import urllib2
 
 
 def GetSuitePaths(test_root):
-  def IsSuite(path):
-    return isdir(path) and exists(join(path, 'testcfg.py'))
-  return [ f for f in os.listdir(test_root) if IsSuite(join(test_root, f)) ]
+  return [ f for f in os.listdir(test_root) if isdir(join(test_root, f)) ]
 
 
 # Reads a file into an array of strings