Title: [121812] trunk/Tools
Revision
121812
Author
[email protected]
Date
2012-07-03 16:53:26 -0700 (Tue, 03 Jul 2012)

Log Message

nrwt: fix mock port
https://bugs.webkit.org/show_bug.cgi?id=90500

Reviewed by Ojan Vafai.

The MockDRT code was never updated when we switched the chromium
ports to using "drt mode" by default. This change updates that
code, fixes a typo in the chromium port that went undetected
(default_test_timeout_ms -> default_timeout_ms), and adds tests
that actually exercise some of the mock ports. These tests are
useful in that they will exercise the port-specific code in an
end-to-end-manner, but they are a bit slow for some reason (>1s
each) that I need to look into.

* Scripts/webkitpy/layout_tests/port/chromium.py:
(ChromiumDriver.stop):
* Scripts/webkitpy/layout_tests/port/chromium_android.py:
(ChromiumAndroidPort.default_timeout_ms):
* Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py:
(TestChromiumAndroidPort.test_default_timeout_ms):
* Scripts/webkitpy/layout_tests/port/mock_drt.py:
(main):
(parse_options):
(MockTestShell):
(MockTestShell.output_for_test):
* Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
(MockDRTTest.assertTest):
(MockTestShellTest):
(MockTestShellTest.make_drt):
(MockTestShellTest.test_test_shell_parse_options):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(PortTest):
(PortTest.assert_mock_port_works):
(PortTest.test_chromium_mac_lion):
(PortTest.test_chromium_mac_lion_in_test_shell_mode):
(PortTest.test_qt_linux):
(PortTest.test_mac_lion):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (121811 => 121812)


--- trunk/Tools/ChangeLog	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/ChangeLog	2012-07-03 23:53:26 UTC (rev 121812)
@@ -1,5 +1,45 @@
 2012-07-03  Dirk Pranke  <[email protected]>
 
+        nrwt: fix mock port
+        https://bugs.webkit.org/show_bug.cgi?id=90500
+
+        Reviewed by Ojan Vafai.
+
+        The MockDRT code was never updated when we switched the chromium
+        ports to using "drt mode" by default. This change updates that
+        code, fixes a typo in the chromium port that went undetected
+        (default_test_timeout_ms -> default_timeout_ms), and adds tests
+        that actually exercise some of the mock ports. These tests are
+        useful in that they will exercise the port-specific code in an
+        end-to-end-manner, but they are a bit slow for some reason (>1s
+        each) that I need to look into.
+
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+        (ChromiumDriver.stop):
+        * Scripts/webkitpy/layout_tests/port/chromium_android.py:
+        (ChromiumAndroidPort.default_timeout_ms):
+        * Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py:
+        (TestChromiumAndroidPort.test_default_timeout_ms):
+        * Scripts/webkitpy/layout_tests/port/mock_drt.py:
+        (main):
+        (parse_options):
+        (MockTestShell):
+        (MockTestShell.output_for_test):
+        * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
+        (MockDRTTest.assertTest):
+        (MockTestShellTest):
+        (MockTestShellTest.make_drt):
+        (MockTestShellTest.test_test_shell_parse_options):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (PortTest):
+        (PortTest.assert_mock_port_works):
+        (PortTest.test_chromium_mac_lion):
+        (PortTest.test_chromium_mac_lion_in_test_shell_mode):
+        (PortTest.test_qt_linux):
+        (PortTest.test_mac_lion):
+
+2012-07-03  Dirk Pranke  <[email protected]>
+
         nrwt: make the worker class stand alone with a cleaner interface
         https://bugs.webkit.org/show_bug.cgi?id=90409
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -693,7 +693,7 @@
             self._proc.stderr.close()
         time_out_ms = self._port.get_option('time_out_ms')
         if time_out_ms and not self._no_timeout:
-            timeout_ratio = float(time_out_ms) / self._port.default_test_timeout_ms()
+            timeout_ratio = float(time_out_ms) / self._port.default_timeout_ms()
             kill_timeout_seconds = self.KILL_TIMEOUT_DEFAULT * timeout_ratio if timeout_ratio > 1.0 else self.KILL_TIMEOUT_DEFAULT
         else:
             kill_timeout_seconds = self.KILL_TIMEOUT_DEFAULT

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -178,7 +178,7 @@
             self._adb_command += shlex.split(adb_args)
         self._drt_retry_after_killed = 0
 
-    def default_test_timeout_ms(self):
+    def default_timeout_ms(self):
         # Android platform has less computing power than desktop platforms.
         # Using 10 seconds allows us to pass most slow tests which are not
         # marked as slow tests on desktop platforms.
@@ -214,7 +214,7 @@
         return True
 
     # FIXME: Remove this function when chromium-android is fully upstream.
-    def expectations_files(self):   
+    def expectations_files(self):
         android_expectations_file = self.path_from_webkit_base('LayoutTests', 'platform', 'chromium', 'test_expectations_android.txt')
         return super(ChromiumAndroidPort, self).expectations_files() + [android_expectations_file]
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -26,6 +26,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import optparse
 import StringIO
 import unittest
 
@@ -49,6 +50,10 @@
         self.assertTrue(port.get_option('enable_hardware_gpu'))
         self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-android'))
 
+    def test_default_timeout_ms(self):
+        self.assertEquals(self.make_port(options=optparse.Values({'configuration': 'Release'})).default_timeout_ms(), 10000)
+        self.assertEquals(self.make_port(options=optparse.Values({'configuration': 'Debug'})).default_timeout_ms(), 10000)
+
     def test_expectations_files(self):
         # FIXME: override this test temporarily while we're still upstreaming the android port and
         # using a custom expectations file.

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -39,6 +39,7 @@
 
 import base64
 import logging
+import optparse
 import os
 import sys
 
@@ -51,7 +52,6 @@
 from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.layout_tests.port.driver import DriverInput, DriverOutput, DriverProxy
 from webkitpy.layout_tests.port.factory import PortFactory
-from webkitpy.tool.mocktool import MockOptions
 
 _log = logging.getLogger(__name__)
 
@@ -130,8 +130,8 @@
     """Run the tests."""
 
     options, args = parse_options(argv)
-    if options.chromium:
-        drt = MockChromiumDRT(options, args, host, stdin, stdout, stderr)
+    if options.test_shell:
+        drt = MockTestShell(options, args, host, stdin, stdout, stderr)
     else:
         drt = MockDRT(options, args, host, stdin, stdout, stderr)
     return drt.run()
@@ -151,16 +151,15 @@
 
     pixel_tests = False
     pixel_path = None
-    chromium = False
-    if platform.startswith('chromium'):
-        chromium = True
+    test_shell = '--test-shell' in argv
+    if test_shell:
         for arg in argv:
             if arg.startswith('--pixel-tests'):
                 pixel_tests = True
                 pixel_path = arg[len('--pixel-tests='):]
     else:
         pixel_tests = '--pixel-tests' in argv
-    options = MockOptions(chromium=chromium, platform=platform, pixel_tests=pixel_tests, pixel_path=pixel_path)
+    options = optparse.Values({'test_shell': test_shell, 'platform': platform, 'pixel_tests': pixel_tests, 'pixel_path': pixel_path})
     return (options, argv)
 
 
@@ -255,7 +254,7 @@
         self._stderr.flush()
 
 
-class MockChromiumDRT(MockDRT):
+class MockTestShell(MockDRT):
     def input_from_line(self, line):
         vals = line.strip().split()
         if len(vals) == 3:
@@ -272,7 +271,7 @@
         original_test_name = test_input.test_name
         if '--enable-accelerated-2d-canvas' in self._args and 'canvas' in test_input.test_name:
             test_input.test_name = 'platform/chromium/virtual/gpu/' + test_input.test_name
-        output = super(MockChromiumDRT, self).output_for_test(test_input, is_reftest)
+        output = super(MockTestShell, self).output_for_test(test_input, is_reftest)
         test_input.test_name = original_test_name
         return output
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -150,7 +150,7 @@
         # We use the StringIO.buflist here instead of getvalue() because
         # the StringIO might be a mix of unicode/ascii and 8-bit strings.
         self.assertEqual(stdout.buflist, drt_output)
-        self.assertEqual(stderr.getvalue(), '' if options.chromium else '#EOF\n')
+        self.assertEqual(stderr.getvalue(), '' if options.test_shell else '#EOF\n')
 
     def test_main(self):
         host = MockSystemHost()
@@ -201,22 +201,21 @@
         self.assertTest('passes/mismatch.html', True, expected_checksum='mock-checksum', expected_text='reference text\n')
 
 
-
-class MockChromiumDRTTest(MockDRTTest):
+class MockTestShellTest(MockDRTTest):
     def extra_args(self, pixel_tests):
         if pixel_tests:
             return ['--pixel-tests=/tmp/png_result0.png']
         return []
 
     def make_drt(self, options, args, host, stdin, stdout, stderr):
-        options.chromium = True
+        options.test_shell = True
 
         # We have to set these by hand because --platform test won't trigger
         # the Chromium code paths.
         options.pixel_path = '/tmp/png_result0.png'
         options.pixel_tests = True
 
-        return mock_drt.MockChromiumDRT(options, args, host, stdin, stdout, stderr)
+        return mock_drt.MockTestShell(options, args, host, stdin, stdout, stderr)
 
     def input_line(self, port, test_name, checksum=None):
         url = ""
@@ -251,10 +250,10 @@
         self.assertEquals(host.filesystem.written_files,
             {'/tmp/png_result0.png': 'image_checksum\x8a-pngtEXtchecksum\x00image_checksum-checksum'})
 
-    def test_chromium_parse_options(self):
-        options, args = mock_drt.parse_options(['--platform', 'chromium-mac',
+    def test_test_shell_parse_options(self):
+        options, args = mock_drt.parse_options(['--platform', 'chromium-mac', '--test-shell',
             '--pixel-tests=/tmp/png_result0.png'])
-        self.assertTrue(options.chromium)
+        self.assertTrue(options.test_shell)
         self.assertTrue(options.pixel_tests)
         self.assertEquals(options.pixel_path, '/tmp/png_result0.png')
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (121811 => 121812)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-07-03 23:47:33 UTC (rev 121811)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-07-03 23:53:26 UTC (rev 121812)
@@ -46,6 +46,7 @@
 from webkitpy.common.system import outputcapture, path
 from webkitpy.common.system.crashlogs_unittest import make_mock_crash_report_darwin
 from webkitpy.common.system.systemhost import SystemHost
+from webkitpy.common.host import Host
 from webkitpy.common.host_mock import MockHost
 
 from webkitpy.layout_tests import port
@@ -1011,5 +1012,21 @@
             "platform/test-mac-leopard/failures/expected/missing_image", [".txt", ".png"], err)
 
 
+class PortTest(unittest.TestCase):
+    def assert_mock_port_works(self, port_name, args=[]):
+        self.assertTrue(passing_run(args + ['--platform', 'mock-' + port_name, 'fast/harness/results.html'], tests_included=True, host=Host()))
+
+    def test_chromium_mac_lion(self):
+        self.assert_mock_port_works('chromium-mac-lion')
+
+    def test_chromium_mac_lion_in_test_shell_mode(self):
+        self.assert_mock_port_works('chromium-mac-lion', args=['--additional-drt-flag=--test-shell'])
+
+    def test_qt_linux(self):
+        self.assert_mock_port_works('qt-linux')
+
+    def test_mac_lion(self):
+        self.assert_mock_port_works('mac-lion')
+
 if __name__ == '__main__':
     unittest.main()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to