diff options
| author | Kristian Monsen <kristianm@google.com> | 2010-09-08 12:18:00 +0100 |
|---|---|---|
| committer | Kristian Monsen <kristianm@google.com> | 2010-09-11 12:08:58 +0100 |
| commit | 5ddde30071f639962dd557c453f2ad01f8f0fd00 (patch) | |
| tree | 775803c4ab35af50aa5f5472cd1fb95fe9d5152d /WebKitTools/Scripts/webkitpy/layout_tests/layout_package | |
| parent | 3e63d9b33b753ca86d0765d1b3d711114ba9e34f (diff) | |
| download | external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.zip external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.gz external_webkit-5ddde30071f639962dd557c453f2ad01f8f0fd00.tar.bz2 | |
Merge WebKit at r66666 : Initial merge by git.
Change-Id: I57dedeb49859adc9c539e760f0e749768c66626f
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/layout_tests/layout_package')
6 files changed, 141 insertions, 51 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py index 6343400..ec33086 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py @@ -169,6 +169,11 @@ class SingleTestThread(threading.Thread): self._output_dir = output_dir def run(self): + self._covered_run() + + def _covered_run(self): + # FIXME: this is a separate routine to work around a bug + # in coverage: see http://bitbucket.org/ned/coveragepy/issue/85. test_info = self._test_info driver = self._port.create_driver(self._image_path, self._shell_args) driver.start() @@ -287,6 +292,11 @@ class TestShellThread(WatchableThread): def run(self): """Delegate main work to a helper method and watch for uncaught exceptions.""" + self._covered_run() + + def _covered_run(self): + # FIXME: this is a separate routine to work around a bug + # in coverage: see http://bitbucket.org/ned/coveragepy/issue/85. self._thread_id = thread.get_ident() self._start_time = time.time() self._num_tests = 0 @@ -303,9 +313,9 @@ class TestShellThread(WatchableThread): self._exception_info = sys.exc_info() self._stop_time = time.time() # Re-raise it and die. - _log.error('%s dying: %s' % (self.getName(), + _log.error('%s dying, exception raised: %s' % (self.getName(), self._exception_info)) - raise + self._stop_time = time.time() def run_in_main_thread(self, test_runner, result_summary): @@ -321,14 +331,8 @@ class TestShellThread(WatchableThread): If test_runner is not None, then we call test_runner.UpdateSummary() with the results of each test.""" - batch_size = 0 + batch_size = self._options.batch_size batch_count = 0 - if self._options.batch_size: - try: - batch_size = int(self._options.batch_size) - except: - _log.info("Ignoring invalid batch size '%s'" % - self._options.batch_size) # Append tests we're running to the existing tests_run.txt file. # This is created in run_webkit_tests.py:_PrepareListsAndPrintOutput. diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream_unittest.py index a9c6d5b..9421ff8 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream_unittest.py @@ -34,7 +34,6 @@ import optparse import pdb import sys import unittest -import logging from webkitpy.common.array_stream import ArrayStream from webkitpy.layout_tests.layout_package import metered_stream @@ -97,13 +96,19 @@ class TestMeteredStream(unittest.TestCase): m.write("foo") self.assertEquals(a.get(), ['foo']) + import logging + b = ArrayStream() + logger = logging.getLogger() + handler = logging.StreamHandler(b) + logger.addHandler(handler) m.update("bar") - # FIXME: figure out how to test that this went to the logger. Is this - # good enough? + logger.handlers.remove(handler) self.assertEquals(a.get(), ['foo']) + self.assertEquals(b.get(), ['bar\n']) m.progress("dropped") self.assertEquals(a.get(), ['foo']) + self.assertEquals(b.get(), ['bar\n']) if __name__ == '__main__': diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing.py index a9e015f..d420631 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing.py @@ -126,19 +126,6 @@ def print_options(): ] -def configure_logging(options, meter): - """Configures the logging system.""" - log_fmt = '%(message)s' - log_datefmt = '%y%m%d %H:%M:%S' - log_level = logging.INFO - if options.verbose: - log_fmt = ('%(asctime)s %(filename)s:%(lineno)-4d %(levelname)s ' - '%(message)s') - log_level = logging.DEBUG - - logging.basicConfig(level=log_level, format=log_fmt, - datefmt=log_datefmt, stream=meter) - def parse_print_options(print_options, verbose, child_processes, is_fully_parallel): @@ -190,6 +177,28 @@ def parse_print_options(print_options, verbose, child_processes, return switches +def _configure_logging(stream, verbose): + log_fmt = '%(message)s' + log_datefmt = '%y%m%d %H:%M:%S' + log_level = logging.INFO + if verbose: + log_fmt = ('%(asctime)s %(filename)s:%(lineno)-4d %(levelname)s ' + '%(message)s') + log_level = logging.DEBUG + + root = logging.getLogger() + handler = logging.StreamHandler(stream) + handler.setFormatter(logging.Formatter(log_fmt, None)) + root.addHandler(handler) + root.setLevel(log_level) + return handler + + +def _restore_logging(handler_to_remove): + root = logging.getLogger() + root.handlers.remove(handler_to_remove) + + class Printer(object): """Class handling all non-debug-logging printing done by run-webkit-tests. @@ -237,12 +246,22 @@ class Printer(object): self._meter = metered_stream.MeteredStream(options.verbose, regular_output) - configure_logging(self._options, self._meter) + self._logging_handler = _configure_logging(self._meter, + options.verbose) self.switches = parse_print_options(options.print_options, options.verbose, child_processes, is_fully_parallel) - # These two routines just hide the implmentation of the switches. + def cleanup(self): + """Restore logging configuration to its initial settings.""" + if self._logging_handler: + _restore_logging(self._logging_handler) + self._logging_handler = None + + def __del__(self): + self.cleanup() + + # These two routines just hide the implementation of the switches. def disabled(self, option): return not option in self.switches diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py index 40c691f..29139d0 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py @@ -37,6 +37,7 @@ import unittest import logging from webkitpy.common import array_stream +from webkitpy.common.system import logtesting from webkitpy.layout_tests import port from webkitpy.layout_tests.layout_package import printing from webkitpy.layout_tests.layout_package import dump_render_tree_thread @@ -53,25 +54,24 @@ def get_options(args): class TestUtilityFunctions(unittest.TestCase): def test_configure_logging(self): - # FIXME: We need to figure out how to reset the basic logger. - # FIXME: If other testing classes call logging.basicConfig() then - # FIXME: these calls become no-ops and we can't control the - # FIXME: configuration to test things properly. options, args = get_options([]) stream = array_stream.ArrayStream() - printing.configure_logging(options, stream) + handler = printing._configure_logging(stream, options.verbose) logging.info("this should be logged") - # self.assertFalse(stream.empty()) + self.assertFalse(stream.empty()) stream.reset() logging.debug("this should not be logged") - # self.assertTrue(stream.empty()) + self.assertTrue(stream.empty()) + + printing._restore_logging(handler) stream.reset() options, args = get_options(['--verbose']) - printing.configure_logging(options, stream) + handler = printing._configure_logging(stream, options.verbose) logging.debug("this should be logged") - # self.assertFalse(stream.empty()) + self.assertFalse(stream.empty()) + printing._restore_logging(handler) def test_print_options(self): options, args = get_options([]) @@ -190,6 +190,14 @@ class Testprinter(unittest.TestCase): do_helper(method_name, switch, 'hello', exp_err, exp_bot) do_helper(method_name, 'everything', 'hello', exp_err, exp_bot) + def test_configure_and_cleanup(self): + # This test verifies that calling cleanup repeatedly and deleting + # the object is safe. + printer, err, out = self.get_printer(['--print', 'everything']) + printer.cleanup() + printer.cleanup() + printer = None + def test_print_actual(self): # Actual results need to be logged to the buildbot's stream. self.do_switch_tests('print_actual', 'actual', to_buildbot=True) @@ -421,11 +429,12 @@ class Testprinter(unittest.TestCase): self.assertFalse(err.empty()) self.assertTrue(out.empty()) - def test_write(self): + def test_write_nothing(self): printer, err, out = self.get_printer(['--print', 'nothing']) printer.write("foo") self.assertTrue(err.empty()) + def test_write_misc(self): printer, err, out = self.get_printer(['--print', 'misc']) printer.write("foo") self.assertFalse(err.empty()) @@ -433,6 +442,7 @@ class Testprinter(unittest.TestCase): printer.write("foo", "config") self.assertTrue(err.empty()) + def test_write_everything(self): printer, err, out = self.get_printer(['--print', 'everything']) printer.write("foo") self.assertFalse(err.empty()) @@ -440,11 +450,10 @@ class Testprinter(unittest.TestCase): printer.write("foo", "config") self.assertFalse(err.empty()) - # FIXME: this should be logged somewhere, but it actually - # disappears into the ether in the logging subsystem. + def test_write_verbose(self): printer, err, out = self.get_printer(['--verbose']) printer.write("foo") - self.assertTrue(err.empty()) + self.assertTrue(not err.empty() and "foo" in err.get()[0]) self.assertTrue(out.empty()) def test_print_unexpected_results(self): diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py index 086321d..3d8349b 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py @@ -477,6 +477,7 @@ class TestExpectationsFile: the updated string. """ + assert(platform) f_orig = self._get_iterable_expectations(self._expectations) f_new = [] @@ -487,6 +488,8 @@ class TestExpectationsFile: lineno += 1 action = self._get_platform_update_action(line, lineno, tests, platform) + assert(action in (NO_CHANGE, REMOVE_TEST, REMOVE_PLATFORM, + ADD_PLATFORMS_EXCEPT_THIS)) if action == NO_CHANGE: # Save the original line back to the file _log.debug('No change to test: %s', line) @@ -522,9 +525,6 @@ class TestExpectationsFile: _log.info('Test updated: ') _log.info(' old: %s', line) _log.info(' new: %s', new_line) - else: - _log.error('Unknown update action: %d; line: %s', - action, line) _log.info('Total tests removed: %d', tests_removed) _log.info('Total tests updated: %d', tests_updated) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py index 22214b0..26eb18d 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py @@ -93,14 +93,16 @@ class Base(unittest.TestCase): self.get_test('failures/expected/image_checksum.html'), self.get_test('failures/expected/crash.html'), self.get_test('failures/expected/missing_text.html'), + self.get_test('failures/expected/image.html'), self.get_test('passes/text.html')] def get_basic_expectations(self): return """ BUG_TEST : failures/expected/text.html = TEXT -BUG_TEST SKIP : failures/expected/crash.html = CRASH -BUG_TEST REBASELINE : failure/expected/missing_image.html = MISSING -BUG_TEST : failures/expected/image_checksum.html = IMAGE +BUG_TEST WONTFIX SKIP : failures/expected/crash.html = CRASH +BUG_TEST REBASELINE : failures/expected/missing_image.html = MISSING +BUG_TEST WONTFIX : failures/expected/image_checksum.html = IMAGE +BUG_TEST WONTFIX WIN : failures/expected/image.html = IMAGE """ def parse_exp(self, expectations, overrides=None, is_lint_mode=False, @@ -125,6 +127,13 @@ class TestExpectationsTest(Base): self.assert_exp('failures/expected/text.html', TEXT) self.assert_exp('failures/expected/image_checksum.html', IMAGE) self.assert_exp('passes/text.html', PASS) + self.assert_exp('failures/expected/image.html', PASS) + + def test_multiple_results(self): + self.parse_exp('BUGX : failures/expected/text.html = TEXT CRASH') + self.assertEqual(self._exp.get_expectations( + self.get_test('failures/expected/text.html')), + set([TEXT, CRASH])) def test_defer(self): self.parse_exp('BUGX DEFER : failures/expected/text.html = TEXT') @@ -183,6 +192,20 @@ BUGX DEFER : failures/expected = IMAGE self.assertRaises(ValueError, self._exp.expectation_to_string, -1) + def test_get_test_set(self): + # Handle some corner cases for this routine not covered by other tests. + self.parse_exp(self.get_basic_expectations()) + s = self._exp._expected_failures.get_test_set(WONTFIX) + self.assertEqual(s, + set([self.get_test('failures/expected/crash.html'), + self.get_test('failures/expected/image_checksum.html')])) + s = self._exp._expected_failures.get_test_set(WONTFIX, CRASH) + self.assertEqual(s, + set([self.get_test('failures/expected/crash.html')])) + s = self._exp._expected_failures.get_test_set(WONTFIX, CRASH, + include_skips=False) + self.assertEqual(s, set([])) + def test_syntax_missing_expectation(self): # This is missing the expectation. self.assertRaises(SyntaxError, self.parse_exp, @@ -230,6 +253,13 @@ BUG_TEST : failures/expected/text.html = IMAGE""") BUG_TEST : failures/expected/text.html = TEXT BUG_TEST : failures/expected/text.html = IMAGE""") + def test_semantic_missing_file(self): + # This should log a non-fatal error. + self.parse_exp('BUG_TEST : missing_file.html = TEXT') + self.assertEqual( + len(self._exp._expected_failures.get_non_fatal_errors()), 1) + + def test_overrides(self): self.parse_exp(self.get_basic_expectations(), """ BUG_OVERRIDE : failures/expected/text.html = IMAGE""") @@ -256,20 +286,43 @@ BUG_OVERRIDE : failures/expected/text.html = IMAGE""") class RebaseliningTest(Base): """Test rebaselining-specific functionality.""" + def assertRemove(self, platform, input_expectations, expected_expectations): + self.parse_exp(input_expectations) + test = self.get_test('failures/expected/text.html') + actual_expectations = self._exp.remove_platform_from_expectations( + test, platform) + self.assertEqual(expected_expectations, actual_expectations) + def test_no_get_rebaselining_failures(self): self.parse_exp(self.get_basic_expectations()) self.assertEqual(len(self._exp.get_rebaselining_failures()), 0) - def test_basic(self): + def test_get_rebaselining_failures_expand(self): self.parse_exp(""" BUG_TEST REBASELINE : failures/expected/text.html = TEXT """) self.assertEqual(len(self._exp.get_rebaselining_failures()), 1) - new_exp_str = self._exp.remove_platform_from_expectations( - self.get_test('failures/expected/text.html'), 'TEST') - # FIXME: actually test rebaselining - # self.assertEqual(new_exp_str, '\n') + def test_remove_expand(self): + self.assertRemove('mac', + 'BUGX REBASELINE : failures/expected/text.html = TEXT\n', + 'BUGX REBASELINE WIN : failures/expected/text.html = TEXT\n') + + def test_remove_mac_win(self): + self.assertRemove('mac', + 'BUGX REBASELINE MAC WIN : failures/expected/text.html = TEXT\n', + 'BUGX REBASELINE WIN : failures/expected/text.html = TEXT\n') + + def test_remove_mac_mac(self): + self.assertRemove('mac', + 'BUGX REBASELINE MAC : failures/expected/text.html = TEXT\n', + '') + + def test_remove_nothing(self): + self.assertRemove('mac', + '\n\n', + '\n\n') + if __name__ == '__main__': unittest.main() |
