diff options
Diffstat (limited to 'Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py')
-rw-r--r-- | Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py b/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py index 4e09f896f..a9e53ddb2 100644 --- a/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py +++ b/Tools/Scripts/webkitpy/tool/bot/layouttestresultsreader.py @@ -1,4 +1,4 @@ -# Copyright (c) 2011 Google Inc. All rights reserved. +# Copyright (c) 2013 Google Inc. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are @@ -35,31 +35,32 @@ from webkitpy.tool.steps.runtests import RunTests _log = logging.getLogger(__name__) +# FIXME: This class no longer has a clear purpose, and should probably +# be made part of Port, or renamed to LayoutTestResultsArchiver or something more fitting? class LayoutTestResultsReader(object): - def __init__(self, tool, archive_directory): - self._tool = tool + def __init__(self, host, results_directory, archive_directory): + self._host = host + self._results_directory = results_directory self._archive_directory = archive_directory # FIXME: This exists for mocking, but should instead be mocked via - # tool.filesystem.read_text_file. They have different error handling at the moment. + # host.filesystem.read_text_file. They have different error handling at the moment. def _read_file_contents(self, path): try: - return self._tool.filesystem.read_text_file(path) + return self._host.filesystem.read_text_file(path) except IOError, e: # File does not exist or can't be read. return None # FIXME: This logic should move to the port object. def _create_layout_test_results(self): - results_path = self._tool.port().layout_tests_results_path() + results_path = self._host.filesystem.join(self._results_directory, "full_results.json") results_html = self._read_file_contents(results_path) if not results_html: return None return LayoutTestResults.results_from_string(results_html) def _create_unit_test_results(self): - results_path = self._tool.port().unit_tests_results_path() - if not results_path: - return None + results_path = self._host.filesystem.join(self._results_directory, "webkit_unit_tests_output.xml") results_xml = self._read_file_contents(results_path) if not results_xml: return None @@ -69,36 +70,28 @@ class LayoutTestResultsReader(object): layout_test_results = self._create_layout_test_results() unit_test_results = self._create_unit_test_results() if layout_test_results: - # FIXME: We should not have to set failure_limit_count, but we - # do until run-webkit-tests can be updated save off the value - # of --exit-after-N-failures in results.html/results.json. - # https://bugs.webkit.org/show_bug.cgi?id=58481 + # FIXME: This is used to detect if we had N failures due to + # N tests failing, or if we hit the "exit-after-n-failures" limit. + # These days we could just check for the "interrupted" key in results.json instead! layout_test_results.set_failure_limit_count(RunTests.NON_INTERACTIVE_FAILURE_LIMIT_COUNT) if unit_test_results: layout_test_results.add_unit_test_failures(unit_test_results) return layout_test_results - def _results_directory(self): - results_path = self._tool.port().layout_tests_results_path() - # FIXME: This is wrong in two ways: - # 1. It assumes that results.html is at the top level of the results tree. - # 2. This uses the "old" ports.py infrastructure instead of the new layout_tests/port - # which will not support Chromium. However the new arch doesn't work with old-run-webkit-tests - # so we have to use this for now. - return self._tool.filesystem.dirname(results_path) - def archive(self, patch): - results_directory = self._results_directory() - results_name, _ = self._tool.filesystem.splitext(self._tool.filesystem.basename(results_directory)) + filesystem = self._host.filesystem + workspace = self._host.workspace + results_directory = self._results_directory + results_name, _ = filesystem.splitext(filesystem.basename(results_directory)) # Note: We name the zip with the bug_id instead of patch_id to match work_item_log_path(). - zip_path = self._tool.workspace.find_unused_filename(self._archive_directory, "%s-%s" % (patch.bug_id(), results_name), "zip") + zip_path = workspace.find_unused_filename(self._archive_directory, "%s-%s" % (patch.bug_id(), results_name), "zip") if not zip_path: return None - if not self._tool.filesystem.isdir(results_directory): + if not filesystem.isdir(results_directory): _log.info("%s does not exist, not archiving." % results_directory) return None - archive = self._tool.workspace.create_zip(zip_path, results_directory) + archive = workspace.create_zip(filesystem.abspath(zip_path), filesystem.abspath(results_directory)) # Remove the results directory to prevent http logs, etc. from getting huge between runs. # We could have create_zip remove the original, but this is more explicit. - self._tool.filesystem.rmtree(results_directory) + filesystem.rmtree(results_directory) return archive |