webkitpy: Add iPhone and iPad ports
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2019 20:12:38 +0000 (20:12 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2019 20:12:38 +0000 (20:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193537
<rdar://problem/47353390>

Reviewed by Lucas Forschler.

Add --iphone-simulator and --ipad-simulator commands to run-webkit-tests which separate iPhone and iPad into separate
ports. Note that this separation is optional, the --ios-simulator command remains.

* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(RunTest.test_device_type_test_division): Drive-by fix.
(RunTest.test_device_type_specific_listing): Ditto.
(RunTest.test_ipad_test_division):
(RunTest):
(RunTest.test_ipad_listing):
* Scripts/webkitpy/port/factory.py:
(platform_options): Add --iphone-simulator and --ipad-simulator flags.
(PortFactory):
* Scripts/webkitpy/port/ios_simulator.py:
(IPhoneSimulatorPort):
(IPadSimulatorPort):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240163 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py
Tools/Scripts/webkitpy/port/factory.py
Tools/Scripts/webkitpy/port/ios_simulator.py

index e107a2d..5d6c1c2 100644 (file)
@@ -1,3 +1,27 @@
+2019-01-18  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Add iPhone and iPad ports
+        https://bugs.webkit.org/show_bug.cgi?id=193537
+        <rdar://problem/47353390>
+
+        Reviewed by Lucas Forschler.
+
+        Add --iphone-simulator and --ipad-simulator commands to run-webkit-tests which separate iPhone and iPad into separate
+        ports. Note that this separation is optional, the --ios-simulator command remains.
+
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (RunTest.test_device_type_test_division): Drive-by fix.
+        (RunTest.test_device_type_specific_listing): Ditto.
+        (RunTest.test_ipad_test_division):
+        (RunTest):
+        (RunTest.test_ipad_listing):
+        * Scripts/webkitpy/port/factory.py:
+        (platform_options): Add --iphone-simulator and --ipad-simulator flags.
+        (PortFactory):
+        * Scripts/webkitpy/port/ios_simulator.py:
+        (IPhoneSimulatorPort):
+        (IPadSimulatorPort):
+
 2019-01-18  Chris Dumez  <cdumez@apple.com>
 
         Regression(PSON) Scroll position is not always restored properly when navigating back
index ba1a151..749ddd9 100644 (file)
 # (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 codecs
 import json
-import logging
-import os
-import platform
-import Queue
-import re
 import StringIO
-import sys
-import thread
-import time
-import threading
 import unittest
 
 from webkitpy.common.system import outputcapture, path
@@ -48,12 +38,9 @@ from webkitpy.common.system.systemhost import SystemHost
 from webkitpy.common.host import Host
 from webkitpy.common.host_mock import MockHost
 
-from webkitpy import port
 from webkitpy.layout_tests import run_webkit_tests
 from webkitpy.layout_tests.models.test_run_results import INTERRUPTED_EXIT_STATUS
-from webkitpy.port import Port
 from webkitpy.port import test
-from webkitpy.test.skip import skip_if
 from webkitpy.xcode.device_type import DeviceType
 
 
@@ -857,7 +844,7 @@ class RunTest(unittest.TestCase, StreamTestingMixin):
         for line in logging.getvalue():
             if str(DeviceType.from_string('iPhone SE')) in line:
                 self.assertTrue('Skipping 2 tests' in line)
-            elif str(DeviceType.from_string('iPhone (5th generation)')) in line:
+            elif str(DeviceType.from_string('iPad (5th generation)')) in line:
                 self.assertTrue('Skipping 1 test' in line)
             elif str(DeviceType.from_string('iPhone 7')) in line:
                 self.assertTrue('Skipping 0 tests' in line)
@@ -881,7 +868,7 @@ class RunTest(unittest.TestCase, StreamTestingMixin):
         current_type = None
         by_type = {}
         for line in output.splitlines():
-            if not line:
+            if not line or 'skip' in line:
                 continue
             if 'Tests to run' in line:
                 current_type = DeviceType.from_string(line.split('for ')[-1].split(' running')[0]) if 'for ' in line else None
@@ -894,6 +881,59 @@ class RunTest(unittest.TestCase, StreamTestingMixin):
         self.assertEqual(1, len(by_type[DeviceType.from_string('iPad (5th generation)')]))
         self.assertEqual(0, len(by_type[DeviceType.from_string('iPhone 7')]))
 
+    def test_ipad_test_division(self):
+        host = MockHost()
+        port = host.port_factory.get('ipad-simulator')
+
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/test1.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/ios/test2.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/ipad/test3.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/iphone/test4.html', '')
+        host.filesystem.write_text_file('/MOCK output of child process/ImageDiff', '')
+
+        oc = outputcapture.OutputCapture()
+        try:
+            oc.capture_output()
+            logging = StringIO.StringIO()
+            run_webkit_tests.run(port, run_webkit_tests.parse_args(['--debug-rwt-logging', '-n', '--no-build', '--root', '/build'])[0], [], logging_stream=logging)
+        finally:
+            output, err, _ = oc.restore_output()
+
+        for line in logging.getvalue():
+            if str(DeviceType.from_string('iPad (5th generation)')) in line:
+                self.assertTrue('Skipping 3 test' in line)
+
+    def test_ipad_listing(self):
+        host = MockHost()
+        port = host.port_factory.get('ipad-simulator')
+
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/test1.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/ios/test2.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/ipad/test3.html', '')
+        host.filesystem.write_text_file('/mock-checkout/LayoutTests/platform/iphone/test4.html', '')
+
+        oc = outputcapture.OutputCapture()
+        try:
+            oc.capture_output()
+            logging = StringIO.StringIO()
+            run_webkit_tests._print_expectations(port, run_webkit_tests.parse_args([])[0], [], logging_stream=logging)
+        finally:
+            output, _, _ = oc.restore_output()
+
+        current_type = None
+        by_type = {}
+        for line in output.splitlines():
+            if not line or 'skip' in line:
+                continue
+            if 'Tests to run' in line:
+                current_type = DeviceType.from_string(line.split('for ')[-1].split(' running')[0]) if 'for ' in line else None
+                by_type[current_type] = []
+                continue
+            by_type[current_type].append(line)
+
+        self.assertEqual(1, len(by_type.keys()))
+        self.assertEqual(3, len(by_type[DeviceType.from_string('iPad (5th generation)')]))
+
 
 class EndToEndTest(unittest.TestCase):
     def test_reftest_with_two_notrefs(self):
index 989f88d..4d3c41f 100644 (file)
@@ -47,6 +47,12 @@ def platform_options(use_globs=False):
         optparse.make_option('--ios-simulator', action='store_const', dest='platform',
             const=('ios-simulator'),
             help=('Alias for --platform=ios-simulator')),
+        optparse.make_option('--iphone-simulator', action='store_const', dest='platform',
+            const=('iphone-simulator'),
+            help=('Alias for --platform=iphone-simulator')),
+        optparse.make_option('--ipad-simulator', action='store_const', dest='platform',
+            const=('ipad-simulator'),
+            help=('Alias for --platform=ipad-simulator')),
         optparse.make_option('--simulator', action='store_const', dest='platform',
             const=('ios-simulator'),
             help=('DEPRECATED alias for --platform=ios-simulator')),
@@ -90,6 +96,8 @@ class PortFactory(object):
     PORT_CLASSES = (
         'gtk.GtkPort',
         'ios_simulator.IOSSimulatorPort',
+        'ios_simulator.IPhoneSimulatorPort',
+        'ios_simulator.IPadSimulatorPort',
         'ios_device.IOSDevicePort',
         'watch_simulator.WatchSimulatorPort',
         'watch_device.WatchDevicePort',
index 2a25d84..c54ac52 100644 (file)
@@ -109,3 +109,20 @@ class IOSSimulatorPort(IOSPort):
 
     def stderr_patterns_to_strip(self):
         return []
+
+
+class IPhoneSimulatorPort(IOSSimulatorPort):
+    port_name = 'iphone-simulator'
+
+    DEVICE_TYPE = DeviceType(hardware_family='iPhone')
+    DEFAULT_DEVICE_TYPES = [
+        DeviceType(hardware_family='iPhone', hardware_type='SE'),
+        DeviceType(hardware_family='iPhone', hardware_type='7'),
+    ]
+
+
+class IPadSimulatorPort(IOSSimulatorPort):
+    port_name = 'ipad-simulator'
+
+    DEVICE_TYPE = DeviceType(hardware_family='iPad')
+    DEFAULT_DEVICE_TYPES = [DeviceType(hardware_family='iPad', hardware_type='(5th generation)')]