Changeset 112298 in webkit


Ignore:
Timestamp:
Mar 27, 2012 12:15:53 PM (12 years ago)
Author:
dpranke@chromium.org
Message:

test-webkitpy: prepare for better test run output
https://bugs.webkit.org/show_bug.cgi?id=82290

Reviewed by Adam Barth.

This code basically re-implements the output of the TextTestRunner default
runner code from unittest, although the implementation is quite
different, in preparation for changing the test output to be
metered and possibly running in parallel.

The output is almost identical to before, except that instead of
logging "test_regular (webkitpy.main.RunnerTest) passed" we log
"webkitpy.main.RunnerTest.test_regular passed". It has always
annoyed me that they invert the names to be harder to read and
so that you can't copy & paste back to the input for
test-webkitpy.

This patch is provided to add a skeleton for unit tests and for
comparison to an upcoming patch that will actually add new
functionality.

  • Scripts/webkitpy/test/main.py:

(Tester.init):
(Tester._configure_logging):
(Tester._run_tests):

  • Scripts/webkitpy/test/runner.py: Added.

(TestRunner):
(TestRunner.init):
(TestRunner.test_name):
(TestRunner.all_test_names):
(TestRunner.run):
(TestRunner.write_result):
(TestRunner.write_summary):

  • Scripts/webkitpy/test/runner_unittest.py: Added.

(FakeModuleSuite):
(FakeModuleSuite.init):
(FakeModuleSuite.str):
(FakeModuleSuite.run):
(FakeTopSuite):
(FakeTopSuite.init):
(FakeLoader):
(FakeLoader.init):
(FakeLoader.top_suite):
(FakeLoader.loadTestsFromName):
(RunnerTest):
(RunnerTest.test_regular):
(RunnerTest.test_verbose):

Location:
trunk/Tools
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r112294 r112298  
     12012-03-27  Dirk Pranke  <dpranke@chromium.org>
     2
     3        test-webkitpy: prepare for better test run output
     4        https://bugs.webkit.org/show_bug.cgi?id=82290
     5
     6        Reviewed by Adam Barth.
     7
     8        This code basically re-implements the output of the TextTestRunner default
     9        runner code from unittest, although the implementation is quite
     10        different, in preparation for changing the test output to be
     11        metered and possibly running in parallel.
     12
     13        The output is almost identical to before, except that instead of
     14        logging "test_regular (webkitpy.main.RunnerTest) passed" we log
     15        "webkitpy.main.RunnerTest.test_regular passed". It has always
     16        annoyed me that they invert the names to be harder to read and
     17        so that you can't copy & paste back to the input for
     18        test-webkitpy.
     19
     20        This patch is provided to add a skeleton for unit tests and for
     21        comparison to an upcoming patch that will actually add new
     22        functionality.
     23
     24        * Scripts/webkitpy/test/main.py:
     25        (Tester.__init__):
     26        (Tester._configure_logging):
     27        (Tester._run_tests):
     28        * Scripts/webkitpy/test/runner.py: Added.
     29        (TestRunner):
     30        (TestRunner.__init__):
     31        (TestRunner.test_name):
     32        (TestRunner.all_test_names):
     33        (TestRunner.run):
     34        (TestRunner.write_result):
     35        (TestRunner.write_summary):
     36        * Scripts/webkitpy/test/runner_unittest.py: Added.
     37        (FakeModuleSuite):
     38        (FakeModuleSuite.__init__):
     39        (FakeModuleSuite.__str__):
     40        (FakeModuleSuite.run):
     41        (FakeTopSuite):
     42        (FakeTopSuite.__init__):
     43        (FakeLoader):
     44        (FakeLoader.__init__):
     45        (FakeLoader.top_suite):
     46        (FakeLoader.loadTestsFromName):
     47        (RunnerTest):
     48        (RunnerTest.test_regular):
     49        (RunnerTest.test_verbose):
     50
    1512012-03-27  Gustavo Noronha Silva  <gns@gnome.org>
    252
  • trunk/Tools/Scripts/webkitpy/test/main.py

    r112168 r112298  
    3333from webkitpy.common.system.filesystem import FileSystem
    3434from webkitpy.test.test_finder import TestFinder
     35from webkitpy.test.runner import TestRunner
    3536
    3637_log = logging.getLogger(__name__)
     
    4142        self._verbosity = 1
    4243        self.finder = TestFinder(filesystem or FileSystem())
     44        self.stream = sys.stderr
    4345
    4446    def add_tree(self, top_directory, starting_subdirectory=None):
     
    9395        logging level as described below.
    9496        """
    95         handler = logging.StreamHandler(sys.stderr)
     97        handler = logging.StreamHandler(self.stream)
    9698        # We constrain the level on the handler rather than on the root
    9799        # logger itself.  This is probably better because the handler is
     
    143145        return self._run_tests(names)
    144146
    145     def _run_tests(self, args):
     147    def _run_tests(self, names):
    146148        if self._options.coverage:
    147149            try:
     
    160162        loader = unittest.defaultTestLoader
    161163        suites = []
    162         for name in args:
     164        for name in names:
    163165            if self.finder.is_module(name):
    164                 # import modules explicitly before loading their tests because
    165                 # loadTestsFromName() produces lousy error messages for bad modules.
     166                # if we failed to load a name and it looks like a module,
     167                # try importing it directly, because loadTestsFromName()
     168                # produces lousy error messages for bad modules.
    166169                try:
    167170                    __import__(name)
     
    170173                    self._log_exception()
    171174                    return False
     175
    172176            suites.append(loader.loadTestsFromName(name, None))
    173177
     
    177181            test_runner = XMLTestRunner(output='test-webkitpy-xml-reports')
    178182        else:
    179             test_runner = unittest.TextTestRunner(verbosity=self._verbosity)
     183            test_runner = TestRunner(self.stream, self._options, loader)
    180184
    181185        _log.debug("Running the tests.")
Note: See TracChangeset for help on using the changeset viewer.