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/run_webkit_tests_unittest.py | |
| 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/run_webkit_tests_unittest.py')
| -rw-r--r-- | WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py | 151 |
1 files changed, 114 insertions, 37 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py index 3a3b14e..4cbfdfc 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py @@ -41,6 +41,7 @@ import threading import unittest from webkitpy.common import array_stream +from webkitpy.common.system import outputcapture from webkitpy.layout_tests import port from webkitpy.layout_tests import run_webkit_tests from webkitpy.layout_tests.layout_package import dump_render_tree_thread @@ -48,75 +49,139 @@ from webkitpy.layout_tests.layout_package import dump_render_tree_thread from webkitpy.thirdparty.mock import Mock -def passing_run(args, port_obj=None, record_results=False, +def passing_run(args=[], port_obj=None, record_results=False, tests_included=False): - args.extend(['--print', 'nothing']) + new_args = ['--print', 'nothing'] + if not '--platform' in args: + new_args.extend(['--platform', 'test']) + if not record_results: + new_args.append('--no-record-results') + new_args.extend(args) if not tests_included: # We use the glob to test that globbing works. - args.extend(['passes', 'failures/expected/*']) - if not record_results: - args.append('--no-record-results') - options, args = run_webkit_tests.parse_args(args) + new_args.extend(['passes', 'failures/expected/*']) + options, parsed_args = run_webkit_tests.parse_args(new_args) if port_obj is None: port_obj = port.get(options.platform, options) - res = run_webkit_tests.run(port_obj, options, args) + res = run_webkit_tests.run(port_obj, options, parsed_args) return res == 0 -def logging_run(args, tests_included=False): - args.extend(['--no-record-results']) +def logging_run(args=[], tests_included=False): + new_args = ['--no-record-results'] + if not '--platform' in args: + new_args.extend(['--platform', 'test']) + if args: + new_args.extend(args) if not tests_included: - args.extend(['passes', 'failures/expected/*']) - options, args = run_webkit_tests.parse_args(args) + new_args.extend(['passes', 'failures/expected/*']) + options, parsed_args = run_webkit_tests.parse_args(new_args) port_obj = port.get(options.platform, options) buildbot_output = array_stream.ArrayStream() regular_output = array_stream.ArrayStream() - res = run_webkit_tests.run(port_obj, options, args, + res = run_webkit_tests.run(port_obj, options, parsed_args, buildbot_output=buildbot_output, regular_output=regular_output) return (res, buildbot_output, regular_output) class MainTest(unittest.TestCase): - def test_fast(self): - self.assertTrue(passing_run(['--platform', 'test'])) - self.assertTrue(passing_run(['--platform', 'test', '--run-singly'])) - self.assertTrue(passing_run(['--platform', 'test', - 'passes/text.html'], tests_included=True)) + def test_basic(self): + self.assertTrue(passing_run()) - def test_unexpected_failures(self): - # Run tests including the unexpected failures. - self.assertFalse(passing_run(['--platform', 'test'], - tests_included=True)) + def test_batch_size(self): + # FIXME: verify # of tests run + self.assertTrue(passing_run(['--batch-size', '2'])) - def test_one_child_process(self): + def test_child_process_1(self): (res, buildbot_output, regular_output) = logging_run( - ['--platform', 'test', '--print', 'config', '--child-processes', - '1']) + ['--print', 'config', '--child-processes', '1']) self.assertTrue('Running one DumpRenderTree\n' in regular_output.get()) - def test_two_child_processes(self): + def test_child_processes_2(self): (res, buildbot_output, regular_output) = logging_run( - ['--platform', 'test', '--print', 'config', '--child-processes', - '2']) + ['--print', 'config', '--child-processes', '2']) self.assertTrue('Running 2 DumpRenderTrees in parallel\n' in regular_output.get()) + def test_exception_raised(self): + self.assertRaises(ValueError, logging_run, + ['failures/expected/exception.html'], tests_included=True) + + def test_full_results_html(self): + # FIXME: verify html? + self.assertTrue(passing_run(['--full-results-html'])) + + def test_help_printing(self): + res, out, err = logging_run(['--help-printing']) + self.assertEqual(res, 0) + self.assertTrue(out.empty()) + self.assertFalse(err.empty()) + + def test_keyboard_interrupt(self): + # Note that this also tests running a test marked as SKIP if + # you specify it explicitly. + self.assertRaises(KeyboardInterrupt, passing_run, + ['failures/expected/keyboard.html'], tests_included=True) + def test_last_results(self): - passing_run(['--platform', 'test'], record_results=True) + passing_run(['--clobber-old-results'], record_results=True) (res, buildbot_output, regular_output) = logging_run( - ['--platform', 'test', '--print-last-failures']) + ['--print-last-failures']) self.assertEqual(regular_output.get(), ['\n\n']) self.assertEqual(buildbot_output.get(), []) + def test_lint_test_files(self): + # FIXME: add errors? + res, out, err = logging_run(['--lint-test-files'], tests_included=True) + self.assertEqual(res, 0) + self.assertTrue(out.empty()) + self.assertTrue(any(['lint succeeded' in msg for msg in err.get()])) + def test_no_tests_found(self): - self.assertRaises(SystemExit, logging_run, - ['--platform', 'test', 'resources'], - tests_included=True) - self.assertRaises(SystemExit, logging_run, - ['--platform', 'test', 'foo'], - tests_included=True) + res, out, err = logging_run(['resources'], tests_included=True) + self.assertEqual(res, -1) + self.assertTrue(out.empty()) + self.assertTrue('No tests to run.\n' in err.get()) + + def test_no_tests_found_2(self): + res, out, err = logging_run(['foo'], tests_included=True) + self.assertEqual(res, -1) + self.assertTrue(out.empty()) + self.assertTrue('No tests to run.\n' in err.get()) + + def test_randomize_order(self): + # FIXME: verify order was shuffled + self.assertTrue(passing_run(['--randomize-order'])) + + def test_run_chunk(self): + # FIXME: verify # of tests run + self.assertTrue(passing_run(['--run-chunk', '1:4'])) + + def test_run_force(self): + # This raises an exception because we run + # failures/expected/exception.html, which is normally SKIPped. + self.assertRaises(ValueError, logging_run, ['--force']) + + def test_run_part(self): + # FIXME: verify # of tests run + self.assertTrue(passing_run(['--run-part', '1:2'])) + + def test_run_singly(self): + self.assertTrue(passing_run(['--run-singly'])) + + def test_single_file(self): + # FIXME: verify # of tests run + self.assertTrue(passing_run(['passes/text.html'], tests_included=True)) + + def test_unexpected_failures(self): + # Run tests including the unexpected failures. + res, out, err = logging_run(tests_included=True) + self.assertEqual(res, 1) + self.assertFalse(out.empty()) + self.assertFalse(err.empty()) + def _mocked_open(original_open, file_list): def _wrapper(name, mode, encoding): @@ -144,7 +209,7 @@ class RebaselineTest(unittest.TestCase): # is missing, update the expected generic location. file_list = [] codecs.open = _mocked_open(original_open, file_list) - passing_run(['--platform', 'test', '--pixel-tests', + passing_run(['--pixel-tests', '--reset-results', 'passes/image.html', 'failures/expected/missing_image.html'], @@ -165,7 +230,7 @@ class RebaselineTest(unittest.TestCase): # is mssing, then create a new expectation in the platform dir. file_list = [] codecs.open = _mocked_open(original_open, file_list) - passing_run(['--platform', 'test', '--pixel-tests', + passing_run(['--pixel-tests', '--new-baseline', 'passes/image.html', 'failures/expected/missing_image.html'], @@ -208,6 +273,7 @@ class DryrunTest(unittest.TestCase): if sys.platform != "darwin": return + self.assertTrue(passing_run(['--platform', 'test'])) self.assertTrue(passing_run(['--platform', 'dryrun', 'fast/html'])) self.assertTrue(passing_run(['--platform', 'dryrun-mac', @@ -223,6 +289,11 @@ class TestThread(dump_render_tree_thread.WatchableThread): self._timeout_queue = Queue.Queue() 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. self._thread_id = thread.get_ident() try: self._started_queue.put('') @@ -284,8 +355,11 @@ class WaitForThreadsToFinishTest(unittest.TestCase): self.assertTrue(interrupted) def test_timeout(self): + oc = outputcapture.OutputCapture() + oc.capture_output() interrupted = self.run_one_thread('Timeout') self.assertFalse(interrupted) + oc.restore_output() def test_exception(self): self.assertRaises(ValueError, self.run_one_thread, 'Exception') @@ -293,6 +367,8 @@ class WaitForThreadsToFinishTest(unittest.TestCase): class StandaloneFunctionsTest(unittest.TestCase): def test_log_wedged_thread(self): + oc = outputcapture.OutputCapture() + oc.capture_output() logger = run_webkit_tests._log astream = array_stream.ArrayStream() handler = TestHandler(astream) @@ -310,6 +386,7 @@ class StandaloneFunctionsTest(unittest.TestCase): self.assertFalse(astream.empty()) self.assertFalse(child_thread.isAlive()) + oc.restore_output() def test_find_thread_stack(self): id, stack = sys._current_frames().items()[0] |
