Changeset 103547 in webkit


Ignore:
Timestamp:
Dec 22, 2011 8:57:08 AM (12 years ago)
Author:
Adam Roben
Message:

Add a --xml flag to test-webkitpy

test-webkitpy --xml will, in addition to providing the standard text output on stdout, write
JUnit-style XML files to a test-webkitpy-xml-reports subdirectory in the working directory.
This is useful for working with tools that consume JUnit-style XML files.

Fixes <http://webkit.org/b/75090> Would like a way to generate JUnit-style XML files when
running test-webkitpy

Reviewed by Darin Adler.

  • Scripts/webkitpy/test/main.py:

(Tester.run_tests): If the --xml flag is passed, create an XMLTestRunner and pass it to
unittest.main(). Otherwise pass no test runner so that unittest will choose its own default.

  • Scripts/webkitpy/thirdparty/init.py:

(AutoinstallImportHook.find_module):
(AutoinstallImportHook._install_xmlrunner):
Added code to install unittest-xml-reporting as webkitpy.thirdparty.autoinstalled.xmlrunner.
This change is untested because it's basically impossible to get a test to pass when --xml
is passed to test-webkitpy (because xmlrunner will already have been imported by the time
the test runs).

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r103546 r103547  
     12011-12-22  Adam Roben  <aroben@apple.com>
     2
     3        Add a --xml flag to test-webkitpy
     4
     5        test-webkitpy --xml will, in addition to providing the standard text output on stdout, write
     6        JUnit-style XML files to a test-webkitpy-xml-reports subdirectory in the working directory.
     7        This is useful for working with tools that consume JUnit-style XML files.
     8
     9        Fixes <http://webkit.org/b/75090> Would like a way to generate JUnit-style XML files when
     10        running test-webkitpy
     11
     12        Reviewed by Darin Adler.
     13
     14        * Scripts/webkitpy/test/main.py:
     15        (Tester.run_tests): If the --xml flag is passed, create an XMLTestRunner and pass it to
     16        unittest.main(). Otherwise pass no test runner so that unittest will choose its own default.
     17
     18        * Scripts/webkitpy/thirdparty/__init__.py:
     19        (AutoinstallImportHook.find_module):
     20        (AutoinstallImportHook._install_xmlrunner):
     21        Added code to install unittest-xml-reporting as webkitpy.thirdparty.autoinstalled.xmlrunner.
     22        This change is untested because it's basically impossible to get a test to pass when --xml
     23        is passed to test-webkitpy (because xmlrunner will already have been imported by the time
     24        the test runs).
     25
    1262011-12-22  David Kilzer  <ddkilzer@apple.com>
    227
  • trunk/Tools/Scripts/webkitpy/test/main.py

    r89791 r103547  
    112112            sys.path.extend(set(os.path.dirname(path) for path in external_package_paths))
    113113
     114        if '--xml' in sys.argv:
     115            sys.argv.remove('--xml')
     116            from webkitpy.thirdparty.autoinstalled.xmlrunner import XMLTestRunner
     117            test_runner = XMLTestRunner(output='test-webkitpy-xml-reports')
     118        else:
     119            test_runner = None
     120
    114121        if len(sys_argv) > 1 and not sys_argv[-1].startswith("-"):
    115122            # Then explicit modules or test names were provided, which
    116123            # the unittest module is equipped to handle.
    117             unittest.main(argv=sys_argv, module=None)
     124            unittest.main(argv=sys_argv, module=None, testRunner=test_runner)
    118125            # No need to return since unitttest.main() exits.
    119126
     
    167174        # this module.)  See the loadTestsFromName() method of the
    168175        # unittest.TestLoader class for more details on this parameter.
    169         unittest.main(argv=sys_argv, module=None)
     176        unittest.main(argv=sys_argv, module=None, testRunner=test_runner)
  • trunk/Tools/Scripts/webkitpy/thirdparty/__init__.py

    r99341 r103547  
    8383        elif '.buildbot' in fullname:
    8484            self._install_buildbot()
     85        elif '.xmlrunner' in fullname:
     86            self._install_xmlrunner()
    8587
    8688    def _install_mechanize(self):
     
    129131                          url_subpath="pywebsocket-0.7/src/mod_pywebsocket")
    130132
     133    def _install_xmlrunner(self):
     134        self._install("http://pypi.python.org/packages/source/u/unittest-xml-reporting/unittest-xml-reporting-1.0.3.tar.gz#md5=cebf83281b0753b5d42bad38c91fd4d6",
     135                      "unittest-xml-reporting-1.0.3/src/xmlrunner")
     136
    131137    def _install(self, url, url_subpath):
    132138        installer = AutoInstaller(target_dir=_AUTOINSTALLED_DIR)
Note: See TracChangeset for help on using the changeset viewer.