+2015-04-24 Daniel Bates <dabates@apple.com>
+
+ Cleanup: Use @memoized for property IOSSimulator.testing_device
+ https://bugs.webkit.org/show_bug.cgi?id=141715
+
+ Reviewed by Darin Adler.
+
+ Simplify the caching of the result of IOSSimulator.testing_device
+ and make the code more readable by making use of the @memoized declarator
+ instead of explicitly managing a private instance variable,
+ IOSSimulator._testing_device, for the cached result.
+
+ * Scripts/webkitpy/port/ios.py:
+ (IOSPort.determine_full_port_name):
+ (IOSSimulatorPort.__init__): Delete instance variable IOSSimulatorPort._testing_device.
+ (IOSSimulatorPort):
+ (IOSSimulatorPort.testing_device): No need to cache the created device object in
+ IOSSimulatorPort._testing_device since we are marking this function @memoized.
+ (IOSSimulatorPort.reset_preferences): Code style fix; inline self.testing_device.path instead
+ of caching in local variable since we only make use of this value exactly once in this function.
+ (IOSPort.__init__): Deleted; The instance variable IOSPort._testing_device has never
+ been used since being added in r178622. So, we can remove this constructor since
+ it's the trivial constructor once we remove the instance variable IOSPort._testing_device.
+
2015-04-24 Anders Carlsson <andersca@apple.com>
Rename -[WKWebsiteDataStore isNonPersistent] to -[WKWebsiteDataStore isPersistent]
port_name = port_name + '-' + major_version_number
return port_name
- def __init__(self, *args, **kwargs):
- super(IOSPort, self).__init__(*args, **kwargs)
-
- self._testing_device = None
-
# Despite their names, these flags do not actually get passed all the way down to webkit-build.
def _build_driver_flags(self):
return ['--sdk', 'iphoneos'] + (['ARCHS=%s' % self.architecture()] if self.architecture() else [])
# with MallocStackLogging enabled.
self.set_option_default("batch_size", 1000)
- self._testing_device = None
-
def driver_name(self):
if self.get_option('driver_name'):
return self.get_option('driver_name')
return stderr, crash_log
@property
+ @memoized
def testing_device(self):
- if self._testing_device is not None:
- return self._testing_device
- self._testing_device = Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
- return self.testing_device
+ return Simulator().lookup_or_create_device(self.simulator_device_type.name + ' WebKit Tester', self.simulator_device_type, self.simulator_runtime)
def look_for_new_crash_logs(self, crashed_processes, start_time):
crash_logs = {}
return self._image_differ.diff_image(expected_contents, actual_contents, tolerance)
def reset_preferences(self):
- simulator_path = self.testing_device.path
- data_path = os.path.join(simulator_path, 'data')
+ data_path = os.path.join(self.testing_device.path, 'data')
if os.path.isdir(data_path):
shutil.rmtree(data_path)