Upstream version 11.39.266.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Tools / Scripts / webkitpy / test / main.py
index a5b675e..da66ee5 100644 (file)
 
 """unit testing code for webkitpy."""
 
+import StringIO
 import logging
 import multiprocessing
 import optparse
 import os
-import StringIO
 import sys
 import time
 import traceback
@@ -94,8 +94,6 @@ class Tester(object):
                           help='run all the tests')
         parser.add_option('-c', '--coverage', action='store_true', default=False,
                           help='generate code coverage info')
-        parser.add_option('-i', '--integration-tests', action='store_true', default=False,
-                          help='run integration tests as well as unit tests'),
         parser.add_option('-j', '--child-processes', action='store', type='int', default=(1 if sys.platform == 'win32' else multiprocessing.cpu_count()),
                           help='number of tests to run in parallel (default=%default)')
         parser.add_option('-p', '--pass-through', action='store_true', default=False,
@@ -119,7 +117,7 @@ class Tester(object):
         # Make sure PYTHONPATH is set up properly.
         sys.path = self.finder.additional_paths(sys.path) + sys.path
 
-        # FIXME: unittest2 needs to be in sys.path for its internal imports to work.
+        # FIXME: coverage needs to be in sys.path for its internal imports to work.
         thirdparty_path = self.webkit_finder.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')
         if not thirdparty_path in sys.path:
             sys.path.append(thirdparty_path)
@@ -166,15 +164,14 @@ class Tester(object):
             return False
 
         self.printer.write_update("Finding the individual test methods ...")
-        loader = _Loader()
-        parallel_tests, serial_tests = self._test_names(loader, names)
+        loader = unittest.TestLoader()
+        tests = self._test_names(loader, names)
 
         self.printer.write_update("Running the tests ...")
-        self.printer.num_tests = len(parallel_tests) + len(serial_tests)
+        self.printer.num_tests = len(tests)
         start = time.time()
         test_runner = Runner(self.printer, loader, self.webkit_finder)
-        test_runner.run(parallel_tests, self._options.child_processes)
-        test_runner.run(serial_tests, 1)
+        test_runner.run(tests, self._options.child_processes)
 
         self.printer.print_result(time.time() - start)
 
@@ -195,28 +192,10 @@ class Tester(object):
         return True
 
     def _test_names(self, loader, names):
-        parallel_test_method_prefixes = ['test_']
-        serial_test_method_prefixes = ['serial_test_']
-        if self._options.integration_tests:
-            parallel_test_method_prefixes.append('integration_test_')
-            serial_test_method_prefixes.append('serial_integration_test_')
-
-        parallel_tests = []
-        loader.test_method_prefixes = parallel_test_method_prefixes
-        for name in names:
-            parallel_tests.extend(self._all_test_names(loader.loadTestsFromName(name, None)))
-
-        serial_tests = []
-        loader.test_method_prefixes = serial_test_method_prefixes
+        tests = []
         for name in names:
-            serial_tests.extend(self._all_test_names(loader.loadTestsFromName(name, None)))
-
-        # loader.loadTestsFromName() will not verify that names begin with one of the test_method_prefixes
-        # if the names were explicitly provided (e.g., MainTest.test_basic), so this means that any individual
-        # tests will be included in both parallel_tests and serial_tests, and we need to de-dup them.
-        serial_tests = list(set(serial_tests).difference(set(parallel_tests)))
-
-        return (parallel_tests, serial_tests)
+            tests.extend(self._all_test_names(loader.loadTestsFromName(name, None)))
+        return tests
 
     def _all_test_names(self, suite):
         names = []
@@ -234,18 +213,6 @@ class Tester(object):
             _log.error('  ' + l.rstrip())
 
 
-class _Loader(unittest.TestLoader):
-    test_method_prefixes = []
-
-    def getTestCaseNames(self, testCaseClass):
-        def isTestMethod(attrname, testCaseClass=testCaseClass):
-            if not hasattr(getattr(testCaseClass, attrname), '__call__'):
-                return False
-            return (any(attrname.startswith(prefix) for prefix in self.test_method_prefixes))
-        testFnNames = filter(isTestMethod, dir(testCaseClass))
-        testFnNames.sort()
-        return testFnNames
-
 
 if __name__ == '__main__':
     sys.exit(main())