Title: [124503] trunk/Tools
Revision
124503
Author
[email protected]
Date
2012-08-02 14:36:45 -0700 (Thu, 02 Aug 2012)

Log Message

test-webkitpy: integrate proper support for integration tests
https://bugs.webkit.org/show_bug.cgi?id=92925

Reviewed by Ojan Vafai.

This patch merges the custom loader I used for integration tests
into the main test-webkitpy code. Integration tests are not run
by default yet, but at least they can be run.

* Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
(MockTestShellTest.test_test_shell_parse_options):
* Scripts/webkitpy/layout_tests/port/port_testcase.py:
(test_path_to_apache_config_file):
* Scripts/webkitpy/layout_tests/servers/http_server_integrationtest.py:
(WebsocketserverTest):
* Scripts/webkitpy/test/main.py:
(Tester._parse_args):
(Tester._run_tests):
(Tester._test_names):
(Tester._log_exception):
(_Loader):
(_Loader.getTestCaseNames):
(_Loader.getTestCaseNames.isTestMethod):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (124502 => 124503)


--- trunk/Tools/ChangeLog	2012-08-02 21:36:16 UTC (rev 124502)
+++ trunk/Tools/ChangeLog	2012-08-02 21:36:45 UTC (rev 124503)
@@ -1,5 +1,31 @@
 2012-08-02  Dirk Pranke  <[email protected]>
 
+        test-webkitpy: integrate proper support for integration tests
+        https://bugs.webkit.org/show_bug.cgi?id=92925
+
+        Reviewed by Ojan Vafai.
+
+        This patch merges the custom loader I used for integration tests
+        into the main test-webkitpy code. Integration tests are not run
+        by default yet, but at least they can be run.
+
+        * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
+        (MockTestShellTest.test_test_shell_parse_options):
+        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
+        (test_path_to_apache_config_file):
+        * Scripts/webkitpy/layout_tests/servers/http_server_integrationtest.py:
+        (WebsocketserverTest):
+        * Scripts/webkitpy/test/main.py:
+        (Tester._parse_args):
+        (Tester._run_tests):
+        (Tester._test_names):
+        (Tester._log_exception):
+        (_Loader):
+        (_Loader.getTestCaseNames):
+        (_Loader.getTestCaseNames.isTestMethod):
+
+2012-08-02  Dirk Pranke  <[email protected]>
+
         test-webkitpy: clean up runner in preparation for running tests serially as necessary
         https://bugs.webkit.org/show_bug.cgi?id=92922
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py (124502 => 124503)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py	2012-08-02 21:36:16 UTC (rev 124502)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py	2012-08-02 21:36:45 UTC (rev 124503)
@@ -259,7 +259,3 @@
         self.assertTrue(options.test_shell)
         self.assertTrue(options.pixel_tests)
         self.assertEquals(options.pixel_path, '/tmp/png_result0.png')
-
-
-if __name__ == '__main__':
-    port_testcase.main()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py (124502 => 124503)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py	2012-08-02 21:36:16 UTC (rev 124502)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py	2012-08-02 21:36:45 UTC (rev 124503)
@@ -569,34 +569,3 @@
         # Mock out _apache_config_file_name_for_platform to ignore the passed sys.platform value.
         port._apache_config_file_name_for_platform = lambda platform: 'httpd.conf'
         self.assertEquals(port._path_to_apache_config_file(), '/mock-checkout/LayoutTests/http/conf/httpd.conf')
-
-
-# FIXME: This class and main() should be merged into test-webkitpy.
-class EnhancedTestLoader(unittest.TestLoader):
-    integration_tests = False
-    unit_tests = True
-
-    def getTestCaseNames(self, testCaseClass):
-        def isTestMethod(attrname, testCaseClass=testCaseClass):
-            if not hasattr(getattr(testCaseClass, attrname), '__call__'):
-                return False
-            return ((self.unit_tests and attrname.startswith('test_')) or
-                    (self.integration_tests and attrname.startswith('integration_test_')))
-        testFnNames = filter(isTestMethod, dir(testCaseClass))
-        testFnNames.sort()
-        return testFnNames
-
-
-def main(argv=None):
-    if argv is None:
-        argv = sys.argv
-
-    test_loader = EnhancedTestLoader()
-    if '-i' in argv:
-        test_loader.integration_tests = True
-        argv.remove('-i')
-    if '--no-unit-tests' in argv:
-        test_loader.unit_tests = False
-        argv.remove('--no-unit-tests')
-
-    unittest.main(argv=argv, testLoader=test_loader)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server_integrationtest.py (124502 => 124503)


--- trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server_integrationtest.py	2012-08-02 21:36:16 UTC (rev 124502)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/servers/http_server_integrationtest.py	2012-08-02 21:36:45 UTC (rev 124503)
@@ -38,9 +38,7 @@
 import tempfile
 import unittest
 
-from webkitpy.layout_tests.port import port_testcase
 
-
 class BaseTest(unittest.TestCase):
     """Basic framework for script tests."""
     HOST = 'localhost'
@@ -145,7 +143,3 @@
     # FIXME: test TLS at some point?
     PORTS = (8880, )
     SCRIPT_NAME = 'new-run-webkit-websocketserver'
-
-
-if __name__ == '__main__':
-    port_testcase.main()

Modified: trunk/Tools/Scripts/webkitpy/test/main.py (124502 => 124503)


--- trunk/Tools/Scripts/webkitpy/test/main.py	2012-08-02 21:36:16 UTC (rev 124502)
+++ trunk/Tools/Scripts/webkitpy/test/main.py	2012-08-02 21:36:45 UTC (rev 124503)
@@ -87,16 +87,18 @@
                           help='run all the tests')
         parser.add_option('-c', '--coverage', action='', default=False,
                           help='generate code coverage info (requires http://pypi.python.org/pypi/coverage)')
+        parser.add_option('-i', '--integration-tests', action='', default=False,
+                          help='run integration tests as well as unit tests'),
+        parser.add_option('-j', '--child-processes', action='', 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='', default=False,
+                          help='be debugger friendly by passing captured output through to the system')
         parser.add_option('-q', '--quiet', action='', default=False,
                           help='run quietly (errors, warnings, and progress only)')
         parser.add_option('-t', '--timing', action='', default=False,
                           help='display per-test execution time (implies --verbose)')
         parser.add_option('-v', '--verbose', action='', default=0,
                           help='verbose output (specify once for individual test results, twice for debug messages)')
-        parser.add_option('-p', '--pass-through', action='', default=False,
-                          help='be debugger friendly by passing captured output through to the system')
-        parser.add_option('-j', '--child-processes', action='', type='int', default=(1 if sys.platform == 'win32' else multiprocessing.cpu_count()),
-                          help='number of tests to run in parallel (default=%default)')
 
         parser.epilog = ('[args...] is an optional list of modules, test_classes, or individual tests. '
                          'If no args are given, all the tests will be run.')
@@ -134,7 +136,7 @@
             return False
 
         self.printer.write_update("Finding the individual test methods ...")
-        loader = unittest.defaultTestLoader
+        loader = _Loader()
         test_names = self._test_names(loader, names)
 
         self.printer.write_update("Running the tests ...")
@@ -167,6 +169,9 @@
         return True
 
     def _test_names(self, loader, names):
+        if self._options.integration_tests:
+            loader.test_method_prefixes.append('integration_test_')
+
         test_names = []
         for name in names:
             test_names.extend(self._all_test_names(loader.loadTestsFromName(name, None)))
@@ -188,5 +193,19 @@
         for l in s.buflist:
             _log.error('  ' + l.rstrip())
 
+
+class _Loader(unittest.TestLoader):
+    test_method_prefixes = ['test_']
+
+    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())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to