- Revision
- 173452
- Author
- [email protected]
- Date
- 2014-09-09 16:31:41 -0700 (Tue, 09 Sep 2014)
Log Message
iOS Simulator: run-webkit-tests chokes on unterminated UTF-8 when writing a test result
https://bugs.webkit.org/show_bug.cgi?id=135551
Reviewed by Daniel Bates.
Prevent printing invalid Unicode strings going to stderr.
Also, make filesystem.py more tolerant about receiving
Unicode (encoded as UTF-8) when writing to files, in the
rare case that an NSError description will make it to
stderr, such as -[LTRelayController createUniqueApp].
* LayoutTestRelay/LayoutTestRelay/LTRelayController.m:
(-[LTRelayController launchSimulator]): Removed.
(-[LTRelayController createUniqueApp]):
Don't explicitly try to uninstall the app. It is automatically handled
when installing an app with the same bundle identifier.
(-[LTRelayController start]):
(-[LTRelayController bootDevice]): Removed.
The device already boots as a part of starting the simulator. Attempting
to boot a second time may cause spurious stderr output.
* Scripts/webkitpy/port/driver.py:
(IOSSimulatorDriver._setup_environ_for_driver):
Explicitly set DEVELOPER_DIR once so xcode-select isn't called.
Open the iOS Simulator once instead of the LayoutTestRelay trying
to do it.
* Scripts/webkitpy/port/ios.py:
(IOSSimulatorPort._get_crash_log):
Make sure stderr is at least an empty string.
(IOSSimulatorPort):
(IOSSimulatorPort.developer_dir):
New property for setting up DEVELOPER_DIR in the driver environment.
Modified Paths
Diff
Modified: trunk/LayoutTests/fast/block/border-fit-with-right-alignment-expected.html
(Binary files differ)
Modified: trunk/Tools/ChangeLog (173451 => 173452)
--- trunk/Tools/ChangeLog 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/ChangeLog 2014-09-09 23:31:41 UTC (rev 173452)
@@ -1,3 +1,37 @@
+2014-08-05 David Farler <[email protected]>
+
+ iOS Simulator: run-webkit-tests chokes on unterminated UTF-8 when writing a test result
+ https://bugs.webkit.org/show_bug.cgi?id=135551
+
+ Reviewed by Daniel Bates.
+
+ Prevent printing invalid Unicode strings going to stderr.
+ Also, make filesystem.py more tolerant about receiving
+ Unicode (encoded as UTF-8) when writing to files, in the
+ rare case that an NSError description will make it to
+ stderr, such as -[LTRelayController createUniqueApp].
+
+ * LayoutTestRelay/LayoutTestRelay/LTRelayController.m:
+ (-[LTRelayController launchSimulator]): Removed.
+ (-[LTRelayController createUniqueApp]):
+ Don't explicitly try to uninstall the app. It is automatically handled
+ when installing an app with the same bundle identifier.
+ (-[LTRelayController start]):
+ (-[LTRelayController bootDevice]): Removed.
+ The device already boots as a part of starting the simulator. Attempting
+ to boot a second time may cause spurious stderr output.
+ * Scripts/webkitpy/port/driver.py:
+ (IOSSimulatorDriver._setup_environ_for_driver):
+ Explicitly set DEVELOPER_DIR once so xcode-select isn't called.
+ Open the iOS Simulator once instead of the LayoutTestRelay trying
+ to do it.
+ * Scripts/webkitpy/port/ios.py:
+ (IOSSimulatorPort._get_crash_log):
+ Make sure stderr is at least an empty string.
+ (IOSSimulatorPort):
+ (IOSSimulatorPort.developer_dir):
+ New property for setting up DEVELOPER_DIR in the driver environment.
+
2014-09-09 Dan Bernstein <[email protected]>
Clean up the MiniBrowser Xcode project
Modified: trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m (173451 => 173452)
--- trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/LayoutTestRelay/LayoutTestRelay/LTRelayController.m 2014-09-09 23:31:41 UTC (rev 173452)
@@ -89,10 +89,13 @@
- (void)readFileHandle:(NSFileHandle *)fileHandle
{
- NSData *data = "" availableData];
- uint8_t bytes[[data length]];
- [data getBytes:bytes length:[data length]];
- [[[self relay] outputStream] write:[data bytes] maxLength:[data length]];
+ @try {
+ NSData *data = "" availableData];
+ [[[self relay] outputStream] write:[data bytes] maxLength:[data length]];
+ } @catch (NSException *e) {
+ // Broken pipe - the dump tool crashed. Time to die.
+ [self didCrashWithMessage:nil];
+ }
}
@@ -133,66 +136,6 @@
exit(EXIT_FAILURE);
}
-- (void)launchSimulator
-{
- NSString *developerDir = [[[NSProcessInfo processInfo] environment] valueForKey:@"DEVELOPER_DIR"];
- if (!developerDir) {
- NSTask *xcodeSelectTask = [[NSTask alloc] init];
- [xcodeSelectTask setLaunchPath:@"/usr/bin/xcode-select"];
- [xcodeSelectTask setArguments:@[@"--print-path"]];
- [xcodeSelectTask setStandardOutput:[NSPipe pipe]];
-
- NSFileHandle *stdoutFileHandle = [[xcodeSelectTask standardOutput] fileHandleForReading];
- [xcodeSelectTask launch];
- [xcodeSelectTask waitUntilExit];
-
- NSData *data = "" readDataToEndOfFile];
- developerDir = [NSString stringWithUTF8String:[data bytes]];
- }
-
- developerDir = [developerDir stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
-
- if (!developerDir || ![developerDir length]) {
- NSLog(@"Not able to determine the path to iOS Simulator.app in your active Xcode.app");
- exit(EXIT_FAILURE);
- }
- NSURL *simulatorURL = [NSURL fileURLWithPath:[developerDir stringByAppendingPathComponent:@"Applications/iOS Simulator.app"]];
-
- NSDictionary *launchConfiguration = @{
- NSWorkspaceLaunchConfigurationArguments: @[
- @"-CurrentDeviceUDID", [[[self device] UDID] UUIDString],
- ]
- };
- NSError *error;
- [[NSWorkspace sharedWorkspace] launchApplicationAtURL:simulatorURL options:NSWorkspaceLaunchDefault configuration:launchConfiguration error:&error];
-
- if (error) {
- NSLog(@"Couldn't launch iOS Simulator from %@: %@", [simulatorURL path], [error description]);
- exit(EXIT_FAILURE);
- }
-
- while ([[self device] state] == SimDeviceStateShutdown) {
- // Wait for device to start booting
- sleep(1);
- }
-}
-
-- (void)bootDevice
-{
- while ([[self device] state] == SimDeviceStateBooting)
- sleep(1);
-
- if ([[self device] state] == SimDeviceStateBooted)
- return;
-
- NSError *error;
- [[self device] bootWithOptions:nil error:&error];
- if (error) {
- NSLog(@"Unable to boot device: %@", [error description]);
- exit(EXIT_FAILURE);
- }
-}
-
- (void)createUniqueApp
{
NSError *error;
@@ -219,14 +162,6 @@
(NSString *)kCFBundleIdentifierKey: [self uniqueAppIdentifier],
};
- if ([[self device] applicationIsInstalled:[self uniqueAppIdentifier] type: nil error: &error]) {
- BOOL uninstalled = [[self device ] uninstallApplication:[self uniqueAppIdentifier] withOptions:nil error:&error];
- if (!uninstalled) {
- NSLog(@"Couldn't uninstall %@: %@", [self uniqueAppIdentifier], [error description]);
- exit(EXIT_FAILURE);
- }
- }
-
[[self device] installApplication:[self uniqueAppURL] withOptions:installOptions error:&error];
if (error) {
NSLog(@"Couldn't install %@: %@", [[self uniqueAppURL] path], [error description]);
@@ -280,8 +215,6 @@
- (void)start
{
- [self launchSimulator];
- [self bootDevice];
[self createUniqueApp];
[[self relay] setup];
[self launchApp];
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem.py (173451 => 173452)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2014-09-09 23:31:41 UTC (rev 173452)
@@ -39,6 +39,7 @@
import tempfile
import time
+
class FileSystem(object):
"""FileSystem interface for webkitpy.
@@ -223,8 +224,8 @@
"""Write the contents to the file at the given location.
The file is written encoded as UTF-8 with no BOM."""
- with codecs.open(path, 'w', 'utf8') as f:
- f.write(contents)
+ with codecs.open(path, 'w', 'utf-8') as f:
+ f.write(contents.decode('utf-8') if type(contents) == str else contents)
def sha1(self, path):
contents = self.read_binary_file(path)
Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (173451 => 173452)
--- trunk/Tools/Scripts/webkitpy/port/driver.py 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py 2014-09-09 23:31:41 UTC (rev 173452)
@@ -513,7 +513,11 @@
]
return [relay_tool] + relay_args + ['--'] + dump_tool_args
+ def _setup_environ_for_driver(self, environment):
+ environment['DEVELOPER_DIR'] = self._port.developer_dir
+ return super(IOSSimulatorDriver, self)._setup_environ_for_driver(environment)
+
class ContentBlock(object):
def __init__(self):
self.content_type = None
Modified: trunk/Tools/Scripts/webkitpy/port/image_diff.py (173451 => 173452)
--- trunk/Tools/Scripts/webkitpy/port/image_diff.py 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/Scripts/webkitpy/port/image_diff.py 2014-09-09 23:31:41 UTC (rev 173452)
@@ -118,7 +118,6 @@
class IOSSimulatorImageDiffer(ImageDiffer):
def _start(self, tolerance):
command = ['xcrun', '-sdk', 'iphonesimulator', 'sim', '--environment=preserve', '--adopt-pid', self._port._path_to_image_diff(), '--tolerance', str(tolerance)]
- print ' '.join(command)
environment = self._port.setup_environ_for_server('ImageDiff')
self._process = self._port._server_process_constructor(self._port, 'ImageDiff', command, environment)
self._process.start()
Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (173451 => 173452)
--- trunk/Tools/Scripts/webkitpy/port/ios.py 2014-09-09 23:21:08 UTC (rev 173451)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py 2014-09-09 23:31:41 UTC (rev 173452)
@@ -101,11 +101,8 @@
def check_build(self, needs_http):
needs_driver = super(IOSSimulatorPort, self).check_build(needs_http)
- return needs_driver and self._check_build_relay() and self._check_build_image_diff()
+ return needs_driver and self._check_build_relay()
- def _path_to_image_diff(self):
- return self._filesystem.join(self._mac_build_directory, 'ImageDiff')
-
def _build_relay(self):
environment = self.host.copy_current_environment()
environment.disable_gcc_smartquotes()
@@ -118,37 +115,10 @@
return False
return True
- def _check_image_diff(self):
- image_diff_path = self._path_to_image_diff()
- if not self._filesystem.exists(image_diff_path):
- _log.error("%s was not found at %s" % ('ImageDiff', image_diff_path))
- return False
- return True
-
- def _check_build_image_diff(self):
- if not self._root_was_set and self.get_option('build') and not self._build_driver():
- return False
- if not self._check_image_diff():
- return False
- return True
-
- def _build_image_diff(self):
- environment = self.host.copy_current_environment()
- environment.disable_gcc_smartquotes()
- env = environment.to_dictionary()
-
- try:
- self._run_script("build-imagediff", env=env)
- except ScriptError, e:
- _log.error(e.message_with_output(output_limit=None))
- return False
- return True
-
def _build_driver(self):
built_tool = super(IOSSimulatorPort, self)._build_driver()
built_relay = self._build_relay()
- built_image_diff = self._build_image_diff()
- return built_tool and built_relay and built_image_diff
+ return built_tool and built_relay
def _build_driver_flags(self):
archs = ['ARCHS=i386'] if self.architecture() == 'x86' else []
@@ -184,6 +154,10 @@
def setup_test_run(self):
self._executive.run_command(['osascript', '-e', 'tell application "iOS Simulator" to quit'])
+ time.sleep(2)
+ self._executive.run_command([
+ 'open', '-a', os.path.join(self.developer_dir, 'Applications', 'iOS Simulator.app'),
+ '--args', '-CurrentDeviceUDID', self.simulator_udid()])
def clean_up_test_run(self):
super(IOSSimulatorPort, self).clean_up_test_run()
@@ -257,7 +231,7 @@
crash_prefix = 'CRASH: '
stderr_lines = []
crash_lines = []
- for line in stderr.splitlines():
+ for line in (stderr or '').splitlines():
crash_lines.append(line) if line.startswith(crash_prefix) else stderr_lines.append(line)
for crash_line in crash_lines:
@@ -370,5 +344,9 @@
_log.warn("xcrun failed; falling back to '%s'." % fallback)
return fallback
+ @property
+ def developer_dir(self):
+ return self._executive.run_command(['xcode-select', '--print-path']).rstrip()
+
def logging_patterns_to_strip(self):
return []