Changeset 57446 in webkit


Ignore:
Timestamp:
Apr 11, 2010 12:41:56 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-11 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Add PrettyPatch links to new-run-webkit-tests output
https://bugs.webkit.org/show_bug.cgi?id=37406

  • Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
    • We're leaking a file handle here, add a FIXME.
  • Scripts/webkitpy/layout_tests/layout_package/test_failures.py:
    • Add pretty diff links.
  • Scripts/webkitpy/layout_tests/port/base.py:
    • Add support for generating pretty diffs using PrettyPatch.
  • Scripts/webkitpy/layout_tests/port/webkit.py:
    • We're leaking another file handle here, another FIXME.
  • Scripts/webkitpy/layout_tests/test_types/image_diff.py:
    • Update write_output_files signature.
  • Scripts/webkitpy/layout_tests/test_types/test_type_base.py:
    • Remove unused arguments from write_output_files.
    • Add support for dumping pretty diffs to write_output_files.
    • Fix a bunch of file descriptor leaks in this file.
  • Scripts/webkitpy/layout_tests/test_types/text_diff.py:
    • Update write_output_files signature.
Location:
trunk/WebKitTools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r57444 r57446  
     12010-04-11  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add PrettyPatch links to new-run-webkit-tests output
     6        https://bugs.webkit.org/show_bug.cgi?id=37406
     7
     8        * Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py:
     9         - We're leaking a file handle here, add a FIXME.
     10        * Scripts/webkitpy/layout_tests/layout_package/test_failures.py:
     11         - Add pretty diff links.
     12        * Scripts/webkitpy/layout_tests/port/base.py:
     13         - Add support for generating pretty diffs using PrettyPatch.
     14        * Scripts/webkitpy/layout_tests/port/webkit.py:
     15         - We're leaking another file handle here, another FIXME.
     16        * Scripts/webkitpy/layout_tests/test_types/image_diff.py:
     17         - Update write_output_files signature.
     18        * Scripts/webkitpy/layout_tests/test_types/test_type_base.py:
     19         - Remove unused arguments from write_output_files.
     20         - Add support for dumping pretty diffs to write_output_files.
     21         - Fix a bunch of file descriptor leaks in this file.
     22        * Scripts/webkitpy/layout_tests/test_types/text_diff.py:
     23         - Update write_output_files signature.
     24
    1252010-04-10  Adam Barth  <abarth@webkit.org>
    226
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py

    r57381 r57446  
    9090        filename = os.path.splitext(filename)[0] + "-stack.txt"
    9191        port.maybe_make_directory(os.path.split(filename)[0])
    92         open(filename, "wb").write(error)
     92        open(filename, "wb").write(error)  # FIXME: This leaks a file handle.
    9393    elif error:
    9494        _log.debug("Previous test output extra lines after dump:\n%s" %
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py

    r57381 r57446  
    111111    def __init__(self, test_type):
    112112        TestFailure.__init__(self)
    113         # TODO(ojan): This class no longer needs to know the test_type.
     113        # FIXME: This class no longer needs to know the test_type.
    114114        self._test_type = test_type
    115115
     
    128128              If out_names is empty, returns the empty string.
    129129        """
     130        # FIXME: Seems like a bad idea to separate the display name data
     131        # from the path data by hard-coding the display name here
     132        # and passing in the path information via out_names.
    130133        links = ['']
    131134        uris = [self.relative_output_filename(filename, fn) for
     
    139142        if len(uris) > 3:
    140143            links.append("<a href='%s'>wdiff</a>" % uris[3])
     144        if len(uris) > 4:
     145            links.append("<a href='%s'>pretty diff</a>" % uris[4])
    141146        return ' '.join(links)
    142147
     
    193198    """Text diff output failed."""
    194199    # Filename suffixes used by ResultHtmlOutput.
     200    # FIXME: Why don't we use the constants from TestTypeBase here?
    195201    OUT_FILENAMES = ["-actual.txt", "-expected.txt", "-diff.txt"]
    196202    OUT_FILENAMES_WDIFF = ["-actual.txt", "-expected.txt", "-diff.txt",
    197                            "-wdiff.html"]
     203                           "-wdiff.html", "-pretty-diff.html"]
    198204
    199205    def __init__(self, test_type, has_wdiff):
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py

    r57444 r57446  
    520520               actual_filename,
    521521               expected_filename]
     522        # FIXME: Why not just check os.exists(executable) once?
    522523        global _wdiff_available
    523524        result = ''
     
    542543            if _wdiff_available:
    543544                try:
     545                    # FIXME: Use Executive() here.
    544546                    wdiff = subprocess.Popen(cmd,
    545547                        stdout=subprocess.PIPE).communicate()[0]
     
    563565        return result
    564566
     567    def pretty_patch_text(self, diff_path):
     568        pretty_patch_path = self.path_from_webkit_base("BugsSite", "PrettyPatch")
     569        prettify_path = os.path.join(pretty_patch_path, "prettify.rb")
     570        command = ["ruby", "-I", pretty_patch_path, prettify_path, diff_path]
     571        return self._executive.run_command(command)
     572
    565573    def default_configuration(self):
    566574        return "Release"
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py

    r57442 r57446  
    164164                result = False
    165165        elif output and diff_filename:
    166             open(diff_filename, 'w').write(output)
     166            open(diff_filename, 'w').write(output)  # FIXME: This leaks a file handle.
    167167        elif sp.timed_out:
    168168            _log.error("ImageDiff timed out on %s" % expected_filename)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py

    r57443 r57446  
    151151        if not os.path.isfile(expected_png_file):
    152152            # Report a missing expected PNG file.
    153             self.write_output_files(port, filename, '', '.checksum',
     153            self.write_output_files(port, filename, '.checksum',
    154154                                    test_args.hash, expected_hash,
    155                                     diff=False, wdiff=False)
     155                                    print_text_diffs=False)
    156156            self._copy_output_png(filename, test_args.png_path, '-actual.png')
    157157            failures.append(test_failures.FailureMissingImage(self))
     
    161161            return failures
    162162
    163 
    164         self.write_output_files(port, filename, '', '.checksum',
     163        self.write_output_files(port, filename, '.checksum',
    165164                                test_args.hash, expected_hash,
    166                                 diff=False, wdiff=False)
     165                                print_text_diffs=False)
    167166        self._copy_output_png(filename, test_args.png_path, '-actual.png')
    168167        self._copy_output_png(filename, expected_png_file, '-expected.png')
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py

    r57256 r57446  
    7171    FILENAME_SUFFIX_DIFF = "-diff"
    7272    FILENAME_SUFFIX_WDIFF = "-wdiff.html"
     73    FILENAME_SUFFIX_PRETTY_PATCH = "-pretty-diff.html"
    7374    FILENAME_SUFFIX_COMPARE = "-diff.png"
    7475
     
    112113        output_path = os.path.join(output_dir, output_file)
    113114        _log.debug('writing new baseline to "%s"' % (output_path))
    114         open(output_path, "wb").write(data)
     115        self._write_into_file_at_path(output_path, data)
    115116
    116117    def output_filename(self, filename, modifier):
     
    150151        raise NotImplemented
    151152
    152     def write_output_files(self, port, filename, test_type, file_type,
    153                            output, expected, diff=True, wdiff=False):
     153    def _write_into_file_at_path(self, file_path, contents):
     154        file = open(file_path, "wb")
     155        file.write(contents)
     156        file.close()
     157
     158    def write_output_files(self, port, filename, file_type,
     159                           output, expected, print_text_diffs=False):
    154160        """Writes the test output, the expected output and optionally the diff
    155161        between the two to files in the results directory.
    156162
    157163        The full output filename of the actual, for example, will be
    158           <filename><test_type>-actual<file_type>
     164          <filename>-actual<file_type>
    159165        For instance,
    160           my_test-simp-actual.txt
     166          my_test-actual.txt
    161167
    162168        Args:
    163169          filename: The test filename
    164           test_type: A string describing the test type, e.g. "simp"
    165170          file_type: A string describing the test output file type, e.g. ".txt"
    166171          output: A string containing the test output
    167172          expected: A string containing the expected test output
    168           diff: if True, write a file containing the diffs too. This should be
    169               False for results that are not text
    170           wdiff: if True, write an HTML file containing word-by-word diffs
     173          print_text_diffs: True for text diffs. (FIXME: We should be able to get this from the file type?)
    171174        """
    172175        self._make_output_directory(filename)
    173         actual_filename = self.output_filename(filename,
    174             test_type + self.FILENAME_SUFFIX_ACTUAL + file_type)
    175         expected_filename = self.output_filename(filename,
    176             test_type + self.FILENAME_SUFFIX_EXPECTED + file_type)
     176        actual_filename = self.output_filename(filename, self.FILENAME_SUFFIX_ACTUAL + file_type)
     177        expected_filename = self.output_filename(filename, self.FILENAME_SUFFIX_EXPECTED + file_type)
    177178        if output:
    178             open(actual_filename, "wb").write(output)
     179            self._write_into_file_at_path(actual_filename, output)
    179180        if expected:
    180             open(expected_filename, "wb").write(expected)
     181            self._write_into_file_at_path(expected_filename, expected)
    181182
    182183        if not output or not expected:
    183184            return
    184185
    185         if diff:
    186             diff = port.diff_text(expected, output, expected_filename,
    187                                   actual_filename)
    188             diff_filename = self.output_filename(filename,
    189                 test_type + self.FILENAME_SUFFIX_DIFF + file_type)
    190             open(diff_filename, "wb").write(diff)
    191 
    192         if wdiff:
    193             # Shell out to wdiff to get colored inline diffs.
    194             wdiff = port.wdiff_text(expected_filename, actual_filename)
    195             filename = self.output_filename(filename, test_type +
    196                                             self.FILENAME_SUFFIX_WDIFF)
    197             out = open(filename, 'wb').write(wdiff)
     186        if not print_text_diffs:
     187            return
     188
     189        diff = port.diff_text(expected, output, expected_filename, actual_filename)
     190        diff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_DIFF + file_type)
     191        self._write_into_file_at_path(diff_filename, diff)
     192
     193        # Shell out to wdiff to get colored inline diffs.
     194        wdiff = port.wdiff_text(expected_filename, actual_filename)
     195        wdiff_filename = self.output_filename(filename, self.FILENAME_SUFFIX_WDIFF)
     196        self._write_into_file_at_path(wdiff_filename, wdiff)
     197
     198        # Use WebKit's PrettyPatch.rb to get an HTML diff.
     199        pretty_patch = port.pretty_patch_text(diff_filename)
     200        pretty_patch_filename = self.output_filename(filename, self.FILENAME_SUFFIX_PRETTY_PATCH)
     201        self._write_into_file_at_path(pretty_patch_filename, pretty_patch)
  • trunk/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py

    r57443 r57446  
    9999        if port.compare_text(output, expected):
    100100            # Text doesn't match, write output files.
    101             self.write_output_files(port, filename, "", ".txt", output,
    102                                     expected, diff=True, wdiff=True)
     101            self.write_output_files(port, filename, ".txt", output,
     102                                    expected, print_text_diffs=True)
    103103
    104104            if expected == '':
Note: See TracChangeset for help on using the changeset viewer.