Changeset 84689 in webkit


Ignore:
Timestamp:
Apr 22, 2011 3:17:28 PM (13 years ago)
Author:
abarth@webkit.org
Message:

2011-04-22 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Factor LayoutTestResultsReader out of CommitQueue
https://bugs.webkit.org/show_bug.cgi?id=59244

This code will be shared with the EWS when they start running tests.

  • Scripts/webkitpy/tool/bot/layouttestresultsreader.py: Added.
  • Scripts/webkitpy/tool/bot/layouttestresultsreader_unittest.py: Added.
  • Scripts/webkitpy/tool/commands/queues.py:
  • Scripts/webkitpy/tool/commands/queues_unittest.py:
Location:
trunk/Tools
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r84676 r84689  
     12011-04-22  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Factor LayoutTestResultsReader out of CommitQueue
     6        https://bugs.webkit.org/show_bug.cgi?id=59244
     7
     8        This code will be shared with the EWS when they start running tests.
     9
     10        * Scripts/webkitpy/tool/bot/layouttestresultsreader.py: Added.
     11        * Scripts/webkitpy/tool/bot/layouttestresultsreader_unittest.py: Added.
     12        * Scripts/webkitpy/tool/commands/queues.py:
     13        * Scripts/webkitpy/tool/commands/queues_unittest.py:
     14
    1152011-04-22  Eric Seidel  <eric@webkit.org>
    216
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues.py

    r84333 r84689  
    4141from webkitpy.common.config.committervalidator import CommitterValidator
    4242from webkitpy.common.net.bugzilla import Attachment
    43 from webkitpy.common.net.layouttestresults import LayoutTestResults
    4443from webkitpy.common.net.statusserver import StatusServer
    4544from webkitpy.common.system.deprecated_logging import error, log
     
    4847from webkitpy.tool.bot.commitqueuetask import CommitQueueTask, CommitQueueTaskDelegate
    4948from webkitpy.tool.bot.feeders import CommitQueueFeeder, EWSFeeder
     49from webkitpy.tool.bot.layouttestresultsreader import LayoutTestResultsReader
    5050from webkitpy.tool.bot.queueengine import QueueEngine, QueueEngineDelegate
    5151from webkitpy.tool.bot.flakytestreporter import FlakyTestReporter
    5252from webkitpy.tool.commands.stepsequence import StepSequenceErrorHandler
    53 from webkitpy.tool.steps.runtests import RunTests
    5453from webkitpy.tool.multicommandtool import Command, TryAgain
    5554
     
    170169    _sleep_duration = 30  # seconds
    171170
    172     # AbstractPatchQueue methods
     171    # AbstractQueue methods
    173172
    174173    def begin_work_queue(self):
     
    252251        AbstractPatchQueue.begin_work_queue(self)
    253252        self.committer_validator = CommitterValidator(self._tool.bugs)
     253        self._layout_test_results_reader = LayoutTestResultsReader(self._tool, self._log_directory())
    254254
    255255    def next_work_item(self):
     
    312312        return self._update_status(message, patch=patch, results_file=failure_log)
    313313
    314     # FIXME: This exists for mocking, but should instead be mocked via
    315     # tool.filesystem.read_text_file.  They have different error handling at the moment.
    316     def _read_file_contents(self, path):
    317         try:
    318             return self._tool.filesystem.read_text_file(path)
    319         except IOError, e:  # File does not exist or can't be read.
    320             return None
    321 
    322     # FIXME: This logic should move to the port object.
    323     def _create_layout_test_results(self):
    324         results_path = self._tool.port().layout_tests_results_path()
    325         results_html = self._read_file_contents(results_path)
    326         if not results_html:
    327             return None
    328         return LayoutTestResults.results_from_string(results_html)
    329 
    330314    def layout_test_results(self):
    331         results = self._create_layout_test_results()
    332         # FIXME: We should not have to set failure_limit_count, but we
    333         # do until run-webkit-tests can be updated save off the value
    334         # of --exit-after-N-failures in results.html/results.json.
    335         # https://bugs.webkit.org/show_bug.cgi?id=58481
    336         if results:
    337             results.set_failure_limit_count(RunTests.NON_INTERACTIVE_FAILURE_LIMIT_COUNT)
    338         return results
    339 
    340     def _results_directory(self):
    341         results_path = self._tool.port().layout_tests_results_path()
    342         # FIXME: This is wrong in two ways:
    343         # 1. It assumes that results.html is at the top level of the results tree.
    344         # 2. This uses the "old" ports.py infrastructure instead of the new layout_tests/port
    345         # which will not support Chromium.  However the new arch doesn't work with old-run-webkit-tests
    346         # so we have to use this for now.
    347         return os.path.dirname(results_path)
     315        return self._layout_test_results_reader.results()
    348316
    349317    def archive_last_layout_test_results(self, patch):
    350         results_directory = self._results_directory()
    351         results_name, _ = os.path.splitext(os.path.basename(results_directory))
    352         # Note: We name the zip with the bug_id instead of patch_id to match work_item_log_path().
    353         zip_path = self._tool.workspace.find_unused_filename(self._log_directory(), "%s-%s" % (patch.bug_id(), results_name), "zip")
    354         if not zip_path:
    355             return None
    356         if not self._tool.filesystem.isdir(results_directory):
    357             log("%s does not exist, not archiving." % results_directory)
    358             return None
    359         archive = self._tool.workspace.create_zip(zip_path, results_directory)
    360         # Remove the results directory to prevent http logs, etc. from getting huge between runs.
    361         # We could have create_zip remove the original, but this is more explicit.
    362         self._tool.filesystem.rmtree(results_directory)
    363         return archive
     318        return self._layout_test_results_reader.archive(patch)
    364319
    365320    def refetch_patch(self, patch):
  • trunk/Tools/Scripts/webkitpy/tool/commands/queues_unittest.py

    r84333 r84689  
    3232from webkitpy.common.checkout.scm import CheckoutNeedsUpdate
    3333from webkitpy.common.net.bugzilla import Attachment
    34 from webkitpy.common.system.filesystem_mock import MockFileSystem
    3534from webkitpy.common.system.outputcapture import OutputCapture
    3635from webkitpy.layout_tests.layout_package import test_results
     
    4140from webkitpy.tool.commands.queuestest import QueuesTest
    4241from webkitpy.tool.commands.stepsequence import StepSequence
    43 from webkitpy.tool.mocktool import MockTool, MockSCM, MockStatusServer
     42from webkitpy.tool.mocktool import MockTool, MockOptions, MockSCM, MockStatusServer
     43
     44
     45class TestCommitQueue(CommitQueue):
     46    def __init__(self, tool=None):
     47        CommitQueue.__init__(self)
     48        if tool:
     49            self.bind_to_tool(tool)
     50        self._options = MockOptions(confirm=False, parent_command="commit-queue")
     51
     52    def begin_work_queue(self):
     53        output_capture = OutputCapture()
     54        output_capture.capture_output()
     55        CommitQueue.begin_work_queue(self)
     56        output_capture.restore_output()
    4457
    4558
     
    172185
    173186
    174 class SecondThoughtsCommitQueue(CommitQueue):
    175     def __init__(self):
     187class SecondThoughtsCommitQueue(TestCommitQueue):
     188    def __init__(self, tool=None):
    176189        self._reject_patch = False
    177         CommitQueue.__init__(self)
     190        TestCommitQueue.__init__(self, tool)
    178191
    179192    def run_command(self, command):
     
    321334
    322335    def test_manual_reject_during_processing(self):
    323         queue = SecondThoughtsCommitQueue()
    324         queue.bind_to_tool(MockTool())
     336        queue = SecondThoughtsCommitQueue(MockTool())
     337        queue.begin_work_queue()
    325338        queue._tool.filesystem.write_text_file('/mock/results.html', '')  # Otherwise the commit-queue will hit a KeyError trying to read the results from the MockFileSystem.
    326339        queue._options = Mock()
     
    337350
    338351    def test_report_flaky_tests(self):
    339         queue = CommitQueue()
    340         queue.bind_to_tool(MockTool())
     352        queue = TestCommitQueue(MockTool())
    341353        expected_stderr = """MOCK bug comment: bug_id=76, cc=None
    342354--- Begin comment ---
     
    379391        OutputCapture().assert_outputs(self, queue.report_flaky_tests, [QueuesTest.mock_work_item, test_results, MockZipFile()], expected_stderr=expected_stderr)
    380392
    381     def test_missing_layout_test_results(self):
    382         queue = CommitQueue()
    383         tool = MockTool()
    384         results_path = '/mock/results.html'
    385         tool.filesystem = MockFileSystem({results_path: None})
    386         queue.bind_to_tool(tool)
    387         # Make sure that our filesystem mock functions as we expect.
    388         self.assertRaises(IOError, tool.filesystem.read_text_file, results_path)
    389         # layout_test_results shouldn't raise even if the results.html file is missing.
    390         self.assertEquals(queue.layout_test_results(), None)
    391 
    392     def test_layout_test_results(self):
    393         queue = CommitQueue()
    394         queue.bind_to_tool(MockTool())
    395         queue._read_file_contents = lambda path: None
    396         self.assertEquals(queue.layout_test_results(), None)
    397         queue._read_file_contents = lambda path: ""
    398         self.assertEquals(queue.layout_test_results(), None)
    399         queue._create_layout_test_results = lambda: LayoutTestResults([])
    400         results = queue.layout_test_results()
    401         self.assertNotEquals(results, None)
    402         self.assertEquals(results.failure_limit_count(), 10)  # This value matches RunTests.NON_INTERACTIVE_FAILURE_LIMIT_COUNT
    403 
    404     def test_archive_last_layout_test_results(self):
    405         queue = CommitQueue()
    406         tool = MockTool()
    407         queue.bind_to_tool(tool)
    408         patch = queue._tool.bugs.fetch_attachment(128)
    409         # Should fail because the results_directory does not exist.
    410         expected_stderr = "/mock does not exist, not archiving.\n"
    411         archive = OutputCapture().assert_outputs(self, queue.archive_last_layout_test_results, [patch], expected_stderr=expected_stderr)
    412         self.assertEqual(archive, None)
    413 
    414         results_directory = "/mock"
    415         # Sanity check what we assume our mock results directory is.
    416         self.assertEqual(queue._results_directory(), results_directory)
    417         tool.filesystem.maybe_make_directory(results_directory)
    418         self.assertTrue(tool.filesystem.exists(results_directory))
    419 
    420         self.assertNotEqual(queue.archive_last_layout_test_results(patch), None)
    421         self.assertFalse(tool.filesystem.exists(results_directory))
    422 
    423393    def test_upload_results_archive_for_patch(self):
    424         queue = CommitQueue()
    425         queue.bind_to_tool(MockTool())
     394        queue = TestCommitQueue(MockTool())
     395        queue.begin_work_queue()
    426396        patch = queue._tool.bugs.fetch_attachment(128)
    427397        expected_stderr = """MOCK add_attachment_to_bug: bug_id=42, description=Archive of layout-test-results from bot filename=layout-test-results.zip
Note: See TracChangeset for help on using the changeset viewer.