Changeset 90078 in webkit


Ignore:
Timestamp:
Jun 29, 2011, 6:48:44 PM (14 years ago)
Author:
eric@webkit.org
Message:

2011-06-29 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Refactor WebKitDriver.run_test into smaller pieces
https://bugs.webkit.org/show_bug.cgi?id=63673

There is no functional change here. Just moving code around.
This is in preparation for adding support for #CRASHED and #CRASHED - WebProcess

  • Scripts/webkitpy/layout_tests/port/webkit.py:
Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r90077 r90078  
     12011-06-29  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Refactor WebKitDriver.run_test into smaller pieces
     6        https://bugs.webkit.org/show_bug.cgi?id=63673
     7
     8        There is no functional change here.  Just moving code around.
     9        This is in preparation for adding support for #CRASHED and #CRASHED - WebProcess
     10
     11        * Scripts/webkitpy/layout_tests/port/webkit.py:
     12
    1132011-06-29  Eric Seidel  <eric@webkit.org>
    214
  • trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py

    r90077 r90078  
    408408        # FIXME: We're assuming that WebKitTestRunner checks this DumpRenderTree-named environment variable.
    409409        environment['DUMPRENDERTREE_TEMP'] = str(self._driver_tempdir)
    410         self._server_process = server_process.ServerProcess(self._port,
    411             self._port.driver_name(), self.cmd_line(), environment)
     410        self._server_process = server_process.ServerProcess(self._port, self._port.driver_name(), self.cmd_line(), environment)
    412411
    413412    def poll(self):
     
    419418        return
    420419
    421     # FIXME: This function is huge.
     420    def detected_crash(self):
     421        # FIXME: We can't just check self._server_process.crashed for two reasons:
     422        # 1. WebKitTestRunner will print "#CRASHED - WebProcess" and then exit if the WebProcess crashes.
     423        # 2. Adam Roben tells me Windows DumpRenderTree can print "#CRASHED" yet still exit cleanly.
     424        return self._server_process.crashed
     425
     426    def _command_from_driver_input(self, driver_input):
     427        uri = self._port.filename_to_uri(driver_input.filename)
     428        command = uri[7:] if uri.startswith("file:///") else uri
     429
     430        if driver_input.image_hash:
     431            # FIXME: Why the leading quote?
     432            command += "'" + driver_input.image_hash
     433        return command + "\n"
     434
     435    def _read_first_block(self, deadline):
     436        """Reads a block from the server_process and returns (text_content, audio_content)."""
     437        if self.detected_crash():
     438            return (None, None)
     439
     440        block = self._read_block(deadline)
     441        if block.content_type == 'audio/wav':
     442            return (None, block.decoded_content)
     443        return (block.decoded_content, None)
     444
     445    def _read_optional_image_block(self, deadline):
     446        """Reads a block from the server_process and returns (image, actual_image_hash)."""
     447        if self.detected_crash():
     448            return (None, None)
     449
     450        block = self._read_block(deadline)
     451        if block.content and block.content_type == 'image/png':
     452            return (block.decoded_content, block.content_hash)
     453        return (None, block.content_hash)
     454
    422455    def run_test(self, driver_input):
    423         uri = self._port.filename_to_uri(driver_input.filename)
    424         if uri.startswith("file:///"):
    425             command = uri[7:]
    426         else:
    427             command = uri
    428 
    429         if driver_input.image_hash:
    430             command += "'" + driver_input.image_hash
    431         command += "\n"
    432 
     456        command = self._command_from_driver_input(driver_input)
    433457        start_time = time.time()
     458        deadline = time.time() + int(driver_input.timeout) / 1000.0
     459
    434460        self._server_process.write(command)
    435 
    436         text = None
    437         image = None
    438         actual_image_hash = None
    439         audio = None
    440         deadline = time.time() + int(driver_input.timeout) / 1000.0
    441 
    442         # First block is either text or audio
    443         if not self._server_process.crashed:
    444             block = self._read_block(deadline)
    445             if block.content_type == 'audio/wav':
    446                 audio = block.decoded_content
    447             else:
    448                 text = block.decoded_content
    449 
    450         # Now read an optional second block of image data
    451         if not self._server_process.crashed:
    452             block = self._read_block(deadline)
    453             if block.content and block.content_type == 'image/png':
    454                 image = block.decoded_content
    455                 actual_image_hash = block.content_hash
    456             elif block.content_hash:
    457                 actual_image_hash = block.content_hash
     461        text, audio = self._read_first_block(deadline)  # First block is either text or audio
     462        image, actual_image_hash = self._read_optional_image_block(deadline)  # The second (optional) block is image data.
    458463
    459464        error_lines = self._server_process.error.splitlines()
     
    465470        error = "\n".join(error_lines)
    466471
    467         # FIXME: This seems like the wrong section of code to be doing this reset in.
     472        # FIXME: This seems like the wrong section of code to be resetting _server_process.error.
    468473        self._server_process.error = ""
    469474        return base.DriverOutput(text, image, actual_image_hash, audio,
    470             crash=self._server_process.crashed, test_time=time.time() - start_time,
     475            crash=self.detected_crash(), test_time=time.time() - start_time,
    471476            timeout=self._server_process.timed_out, error=error)
    472477
     
    487492        line = self._server_process.read_line(timeout)
    488493        eof = False
    489         while (not self._server_process.timed_out and not self._server_process.crashed and not eof):
     494        while (not self._server_process.timed_out and not self.detected_crash() and not eof):
    490495            chomped_line = line.rstrip()
    491496            if chomped_line.endswith("#EOF"):
Note: See TracChangeset for help on using the changeset viewer.