- Revision
- 112561
- Author
- [email protected]
- Date
- 2012-03-29 12:29:53 -0700 (Thu, 29 Mar 2012)
Log Message
test-webkitpy: add --timing
https://bugs.webkit.org/show_bug.cgi?id=82550
Reviewed by Eric Seidel.
This patch adds a --timing option that will display the time
each test takes. It also removes the --silent option, since
probably no one ever used it, and cleans up the logging
option parsing code to be easier to follow.
* Scripts/webkitpy/test/main.py:
(Tester._parse_args):
(Tester._configure):
* Scripts/webkitpy/test/runner.py:
(TestRunner.write_result):
* Scripts/webkitpy/test/runner_unittest.py:
(RunnerTest.test_regular):
(RunnerTest.test_verbose):
(RunnerTest):
(RunnerTest.test_timing):
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (112560 => 112561)
--- trunk/Tools/ChangeLog 2012-03-29 19:25:48 UTC (rev 112560)
+++ trunk/Tools/ChangeLog 2012-03-29 19:29:53 UTC (rev 112561)
@@ -1,3 +1,26 @@
+2012-03-29 Dirk Pranke <[email protected]>
+
+ test-webkitpy: add --timing
+ https://bugs.webkit.org/show_bug.cgi?id=82550
+
+ Reviewed by Eric Seidel.
+
+ This patch adds a --timing option that will display the time
+ each test takes. It also removes the --silent option, since
+ probably no one ever used it, and cleans up the logging
+ option parsing code to be easier to follow.
+
+ * Scripts/webkitpy/test/main.py:
+ (Tester._parse_args):
+ (Tester._configure):
+ * Scripts/webkitpy/test/runner.py:
+ (TestRunner.write_result):
+ * Scripts/webkitpy/test/runner_unittest.py:
+ (RunnerTest.test_regular):
+ (RunnerTest.test_verbose):
+ (RunnerTest):
+ (RunnerTest.test_timing):
+
2012-03-29 Caio Marcelo de Oliveira Filho <[email protected]>
HashMap<>::add should return a more descriptive object
Modified: trunk/Tools/Scripts/webkitpy/test/main.py (112560 => 112561)
--- trunk/Tools/Scripts/webkitpy/test/main.py 2012-03-29 19:25:48 UTC (rev 112560)
+++ trunk/Tools/Scripts/webkitpy/test/main.py 2012-03-29 19:29:53 UTC (rev 112561)
@@ -1,3 +1,4 @@
+# Copyright (C) 2012 Google, Inc.
# Copyright (C) 2010 Chris Jerdonek ([email protected])
#
# Redistribution and use in source and binary forms, with or without
@@ -38,7 +39,6 @@
class Tester(object):
def __init__(self, filesystem=None):
- self._verbosity = 1
self.finder = TestFinder(filesystem or FileSystem())
self.stream = sys.stderr
@@ -53,8 +53,8 @@
help='generate code coverage info (requires http://pypi.python.org/pypi/coverage)'),
parser.add_option('-q', '--quiet', action='', default=False,
help='run quietly (errors, warnings, and progress only)'),
- parser.add_option('-s', '--silent', action='', default=False,
- help='run silently (errors and warnings only)'),
+ parser.add_option('-t', '--timing', action='', default=False,
+ help='display per-test execution time (implies --verbose)'),
parser.add_option('-x', '--xml', action='', default=False,
help='output xUnit-style XML output')
parser.add_option('-v', '--verbose', action='', default=0,
@@ -70,21 +70,16 @@
def _configure(self, options):
self._options = options
- if options.silent:
- self._verbosity = 0
- self._configure_logging(logging.WARNING)
- elif options.quiet:
- self._verbosity = 1
- self._configure_logging(logging.WARNING)
- elif options.verbose == 0:
- self._verbosity = 1
- self._configure_logging(logging.INFO)
- elif options.verbose == 1:
- self._verbosity = 2
- self._configure_logging(logging.INFO)
+ if options.timing:
+ # --timing implies --verbose
+ options.verbose = max(options.verbose, 1)
+
+ log_level = logging.INFO
+ if options.quiet:
+ log_level = logging.WARNING
elif options.verbose == 2:
- self._verbosity = 2
- self._configure_logging(logging.DEBUG)
+ log_level = logging.DEBUG
+ self._configure_logging(log_level)
def _configure_logging(self, log_level):
"""Configure the root logger.
Modified: trunk/Tools/Scripts/webkitpy/test/runner.py (112560 => 112561)
--- trunk/Tools/Scripts/webkitpy/test/runner.py 2012-03-29 19:25:48 UTC (rev 112560)
+++ trunk/Tools/Scripts/webkitpy/test/runner.py 2012-03-29 19:29:53 UTC (rev 112561)
@@ -82,6 +82,9 @@
return result
def write_result(self, result, test_name, test_time, failure=None, err=None):
+ timing = ''
+ if self.options.timing:
+ timing = ' %.4fs' % test_time
if self.options.verbose:
if failure:
msg = ' failed'
@@ -89,7 +92,7 @@
msg = ' erred'
else:
msg = ' passed'
- self.stream.write(msg + '\n')
+ self.stream.write(msg + timing + '\n')
else:
if failure:
msg = 'F'
Modified: trunk/Tools/Scripts/webkitpy/test/runner_unittest.py (112560 => 112561)
--- trunk/Tools/Scripts/webkitpy/test/runner_unittest.py 2012-03-29 19:25:48 UTC (rev 112560)
+++ trunk/Tools/Scripts/webkitpy/test/runner_unittest.py 2012-03-29 19:29:53 UTC (rev 112561)
@@ -69,7 +69,7 @@
class RunnerTest(unittest.TestCase):
def test_regular(self):
- options = MockOptions(verbose=False)
+ options = MockOptions(verbose=0, timing=False)
stream = StringIO.StringIO()
loader = FakeLoader(('test1 (Foo)', '.', ''),
('test2 (Foo)', 'F', 'test2\nfailed'),
@@ -82,7 +82,7 @@
# FIXME: check the output from the test
def test_verbose(self):
- options = MockOptions(verbose=True)
+ options = MockOptions(verbose=1, timing=False)
stream = StringIO.StringIO()
loader = FakeLoader(('test1 (Foo)', '.', ''),
('test2 (Foo)', 'F', 'test2\nfailed'),
@@ -94,6 +94,19 @@
self.assertEquals(len(result.errors), 1)
# FIXME: check the output from the test
+ def test_timing(self):
+ options = MockOptions(verbose=0, timing=True)
+ stream = StringIO.StringIO()
+ loader = FakeLoader(('test1 (Foo)', '.', ''),
+ ('test2 (Foo)', 'F', 'test2\nfailed'),
+ ('test3 (Foo)', 'E', 'test3\nerred'))
+ result = TestRunner(stream, options, loader).run(loader.top_suite())
+ self.assertFalse(result.wasSuccessful())
+ self.assertEquals(result.testsRun, 3)
+ self.assertEquals(len(result.failures), 1)
+ self.assertEquals(len(result.errors), 1)
+ # FIXME: check the output from the test
+
if __name__ == '__main__':
unittest.main()