Title: [252722] trunk/Tools
Revision
252722
Author
[email protected]
Date
2019-11-20 17:25:19 -0800 (Wed, 20 Nov 2019)

Log Message

run-webkit-tests: Do not create global SystemHost objects
https://bugs.webkit.org/show_bug.cgi?id=204426

Reviewed by Aakash Jain.

If created, SystemHost objects should be created on-demand, not globally
shared between all instances of a function.

* Scripts/webkitpy/xcode/simulated_device.py:
(SimulatedDeviceManager.populate_available_devices):
(SimulatedDeviceManager.available_devices):
(SimulatedDeviceManager.device_by_filter):
(SimulatedDeviceManager._create_or_find_device_for_request):
(SimulatedDeviceManager._boot_device):
(SimulatedDeviceManager.device_count_for_type):
(SimulatedDeviceManager.initialize_devices):
(SimulatedDeviceManager.max_supported_simulators):
(SimulatedDeviceManager.swap):
(SimulatedDeviceManager.tear_down):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (252721 => 252722)


--- trunk/Tools/ChangeLog	2019-11-21 01:16:22 UTC (rev 252721)
+++ trunk/Tools/ChangeLog	2019-11-21 01:25:19 UTC (rev 252722)
@@ -1,3 +1,25 @@
+2019-11-20  Jonathan Bedard  <[email protected]>
+
+        run-webkit-tests: Do not create global SystemHost objects
+        https://bugs.webkit.org/show_bug.cgi?id=204426
+
+        Reviewed by Aakash Jain.
+
+        If created, SystemHost objects should be created on-demand, not globally
+        shared between all instances of a function.
+
+        * Scripts/webkitpy/xcode/simulated_device.py:
+        (SimulatedDeviceManager.populate_available_devices):
+        (SimulatedDeviceManager.available_devices):
+        (SimulatedDeviceManager.device_by_filter):
+        (SimulatedDeviceManager._create_or_find_device_for_request):
+        (SimulatedDeviceManager._boot_device):
+        (SimulatedDeviceManager.device_count_for_type):
+        (SimulatedDeviceManager.initialize_devices):
+        (SimulatedDeviceManager.max_supported_simulators):
+        (SimulatedDeviceManager.swap):
+        (SimulatedDeviceManager.tear_down):
+
 2019-11-20  Wenson Hsieh  <[email protected]>
 
         Correct argument types in UIScriptController::activateDataListSuggestion after r252062

Modified: trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py (252721 => 252722)


--- trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py	2019-11-21 01:16:22 UTC (rev 252721)
+++ trunk/Tools/Scripts/webkitpy/xcode/simulated_device.py	2019-11-21 01:25:19 UTC (rev 252722)
@@ -123,7 +123,8 @@
         return result
 
     @staticmethod
-    def populate_available_devices(host=SystemHost()):
+    def populate_available_devices(host=None):
+        host = host or SystemHost()
         if not host.platform.is_mac():
             return
 
@@ -157,13 +158,15 @@
         return
 
     @staticmethod
-    def available_devices(host=SystemHost()):
+    def available_devices(host=None):
+        host = host or SystemHost()
         if SimulatedDeviceManager.AVAILABLE_DEVICES == []:
             SimulatedDeviceManager.populate_available_devices(host)
         return SimulatedDeviceManager.AVAILABLE_DEVICES
 
     @staticmethod
-    def device_by_filter(filter, host=SystemHost()):
+    def device_by_filter(filter, host=None):
+        host = host or SystemHost()
         result = []
         for device in SimulatedDeviceManager.available_devices(host):
             if filter(device):
@@ -249,8 +252,9 @@
         return None
 
     @staticmethod
-    def _create_or_find_device_for_request(request, host=SystemHost(), name_base='Managed'):
+    def _create_or_find_device_for_request(request, host=None, name_base='Managed'):
         assert isinstance(request, DeviceRequest)
+        host = host or SystemHost()
 
         device = SimulatedDeviceManager._find_exisiting_device_for_request(request)
         if device:
@@ -333,7 +337,8 @@
             time.sleep(1)
 
     @staticmethod
-    def _boot_device(device, host=SystemHost()):
+    def _boot_device(device, host=None):
+        host = host or SystemHost()
         _log.debug(u"Booting device '{}'".format(device.udid))
         device.platform_device.booted_by_script = True
         host.executive.run_command([SimulatedDeviceManager.xcrun, 'simctl', 'boot', device.udid])
@@ -340,7 +345,8 @@
         SimulatedDeviceManager.INITIALIZED_DEVICES.append(device)
 
     @staticmethod
-    def device_count_for_type(device_type, host=SystemHost(), use_booted_simulator=True, **kwargs):
+    def device_count_for_type(device_type, host=None, use_booted_simulator=True, **kwargs):
+        host = host or SystemHost()
         if not host.platform.is_mac():
             return 0
 
@@ -354,7 +360,8 @@
         return 0
 
     @staticmethod
-    def initialize_devices(requests, host=SystemHost(), name_base='Managed', simulator_ui=True, timeout=SIMULATOR_BOOT_TIMEOUT, **kwargs):
+    def initialize_devices(requests, host=None, name_base='Managed', simulator_ui=True, timeout=SIMULATOR_BOOT_TIMEOUT, **kwargs):
+        host = host or SystemHost()
         if SimulatedDeviceManager.INITIALIZED_DEVICES is not None:
             return SimulatedDeviceManager.INITIALIZED_DEVICES
 
@@ -410,7 +417,8 @@
 
     @staticmethod
     @memoized
-    def max_supported_simulators(host=SystemHost()):
+    def max_supported_simulators(host=None):
+        host = host or SystemHost()
         if not host.platform.is_mac():
             return 0
 
@@ -438,7 +446,8 @@
         return min(max_supported_simulators_locally, max_supported_simulators_for_hardware)
 
     @staticmethod
-    def swap(device, request, host=SystemHost(), name_base='Managed', timeout=SIMULATOR_BOOT_TIMEOUT):
+    def swap(device, request, host=None, name_base='Managed', timeout=SIMULATOR_BOOT_TIMEOUT):
+        host = host or SystemHost()
         if SimulatedDeviceManager.INITIALIZED_DEVICES is None:
             raise RuntimeError('Cannot swap when there are no initialized devices')
         if device not in SimulatedDeviceManager.INITIALIZED_DEVICES:
@@ -461,7 +470,8 @@
         SimulatedDeviceManager._wait_until_device_is_usable(device, max(0, deadline - time.time()))
 
     @staticmethod
-    def tear_down(host=SystemHost(), timeout=SIMULATOR_BOOT_TIMEOUT):
+    def tear_down(host=None, timeout=SIMULATOR_BOOT_TIMEOUT):
+        host = host or SystemHost()
         if SimulatedDeviceManager._managing_simulator_app:
             host.executive.run_command(['killall', '-9', 'Simulator'], return_exit_code=True)
             SimulatedDeviceManager._managing_simulator_app = False
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to