WebKitTools/ChangeLog

112010-04-12 Dirk Pranke <dpranke@chromium.org>
22
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Add some very minimal unit tests for new-run-webkit-tests. This should
 6 be enough to catch egregious brokenness like syntax errors and import
 7 declaration issues.
 8
 9 https://bugs.webkit.org/show_bug.cgi?id=37432
 10
 11 * Scripts/webkitpy/layout_tests/run_webkit_tests.py:
 12 * Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py: Added.
 13
 142010-04-12 Dirk Pranke <dpranke@chromium.org>
 15
316 Reviewed by Eric Seidel.
417
518 Modify run_webkit_tests.py to not call sys.exit() at the end of test

WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests.py

@@class TestRunner:
604604 """Returns whether the test runner needs an HTTP server."""
605605 return self._contains_tests(self.HTTP_SUBDIR)
606606
607  def run(self, result_summary):
 607 def run(self, result_summary, print_results):
608608 """Run all our tests on all our test files.
609609
610610 For each test file, we run each test type. If there are any failures,

@@class TestRunner:
612612
613613 Args:
614614 result_summary: a summary object tracking the test results.
 615 print_results: whether or not to print the summary at the end
615616
616617 Return:
617618 The number of unexpected results (0 == success)

@@class TestRunner:
667668 sys.stdout.flush()
668669 sys.stderr.flush()
669670
670  if (LOG_DETAILED_PROGRESS in self._options.log or
671  (LOG_UNEXPECTED in self._options.log and
672  result_summary.total != result_summary.expected)):
673  print
674 
675671 # This summary data gets written to stdout regardless of log level
676  self._print_one_line_summary(result_summary.total,
677  result_summary.expected)
 672 # (unless of course we're printing nothing).
 673 if print_results:
 674 if (LOG_DETAILED_PROGRESS in self._options.log or
 675 (LOG_UNEXPECTED in self._options.log and
 676 result_summary.total != result_summary.expected)):
 677 print
 678 self._print_one_line_summary(result_summary.total,
 679 result_summary.expected)
678680
679681 unexpected_results = self._summarize_unexpected_results(result_summary,
680682 retry_summary)

@@def create_logging_writer(options, log_option):
13671369 return lambda str: 1
13681370
13691371
1370 def main(options, args):
 1372def main(options, args, print_results=True):
13711373 """Run the tests.
13721374
13731375 Args:
13741376 options: a dictionary of command line options
13751377 args: a list of sub directories or files to test
 1378 print_results: whether or not to log anything to stdout.
 1379 Set to false by the unit tests
13761380 Returns:
13771381 the number of unexpected results that occurred, or -1 if there is an
13781382 error.

@@def main(options, args):
15161520 if options.fuzzy_pixel_tests:
15171521 test_runner.add_test_type(fuzzy_image_diff.FuzzyImageDiff)
15181522
1519  num_unexpected_results = test_runner.run(result_summary)
 1523 num_unexpected_results = test_runner.run(result_summary, print_results)
15201524
15211525 port_obj.stop_helper()
15221526

WebKitTools/Scripts/webkitpy/layout_tests/run_webkit_tests_unittest.py

 1#!/usr/bin/python
 2# Copyright (C) 2010 Google Inc. All rights reserved.
 3#
 4# Redistribution and use in source and binary forms, with or without
 5# modification, are permitted provided that the following conditions are
 6# met:
 7#
 8# * Redistributions of source code must retain the above copyright
 9# notice, this list of conditions and the following disclaimer.
 10# * Redistributions in binary form must reproduce the above
 11# copyright notice, this list of conditions and the following disclaimer
 12# in the documentation and/or other materials provided with the
 13# distribution.
 14# * Neither the name of Google Inc. nor the names of its
 15# contributors may be used to endorse or promote products derived from
 16# this software without specific prior written permission.
 17#
 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 19# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 20# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 21# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 22# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 23# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 24# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 25# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 26# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 28# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29
 30"""Unit tests for run_webkit_tests."""
 31
 32import os
 33import sys
 34import unittest
 35
 36import run_webkit_tests
 37
 38
 39def passing_run(args):
 40 options, args = run_webkit_tests.parse_args(args)
 41 res = run_webkit_tests.main(options, args, False)
 42 return res == 0
 43
 44
 45class MainTest(unittest.TestCase):
 46 def test_fast(self):
 47 self.assertTrue(passing_run(['--platform', 'test',
 48 'fast/html']))
 49 self.assertTrue(passing_run(['--platform', 'test',
 50 '--run-singly',
 51 'fast/html']))
 52 self.assertTrue(passing_run(['--platform', 'test',
 53 'fast/html/article-element.html']))
 54 self.assertTrue(passing_run(['--platform', 'test',
 55 '--child-processes', '1',
 56 '--log', 'unexpected',
 57 'fast/html']))
 58
 59if __name__ == '__main__':
 60 unittest.main()