Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: testing/iossim/iossim.mm

Issue 2240373002: [iossim] Work around pipe hang on some macs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #import <Foundation/Foundation.h> 4 #import <Foundation/Foundation.h>
5 #if defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 5 #if defined(__MAC_10_12) && __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12
6 #include <getopt.h> 6 #include <getopt.h>
7 #include <string> 7 #include <string>
8 8
9 namespace { 9 namespace {
10 10
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 - (void)setStandardError:(id)error { 83 - (void)setStandardError:(id)error {
84 [_task setStandardError:error]; 84 [_task setStandardError:error];
85 } 85 }
86 86
87 - (void)run { 87 - (void)run {
88 [_task launch]; 88 [_task launch];
89 [_task waitUntilExit]; 89 [_task waitUntilExit];
90 } 90 }
91 91
92 - (void)launch {
93 [_task launch];
94 }
95
96 - (void)waitUntilExit {
97 [_task waitUntilExit];
98 }
99
92 @end 100 @end
93 101
94 // Return array of available iOS runtime dictionaries. Unavailable (old Xcode 102 // Return array of available iOS runtime dictionaries. Unavailable (old Xcode
95 // versions) or other runtimes (tvOS, watchOS) are removed. 103 // versions) or other runtimes (tvOS, watchOS) are removed.
96 NSArray* Runtimes(NSDictionary* simctl_list) { 104 NSArray* Runtimes(NSDictionary* simctl_list) {
97 NSMutableArray* runtimes = 105 NSMutableArray* runtimes =
98 [[simctl_list[@"runtimes"] mutableCopy] autorelease]; 106 [[simctl_list[@"runtimes"] mutableCopy] autorelease];
99 for (NSDictionary* runtime in simctl_list[@"runtimes"]) { 107 for (NSDictionary* runtime in simctl_list[@"runtimes"]) {
100 if (![runtime[@"identifier"] 108 if (![runtime[@"identifier"]
101 hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] || 109 hasPrefix:@"com.apple.CoreSimulator.SimRuntime.iOS"] ||
(...skipping 18 matching lines...) Expand all
120 } 128 }
121 return devicetypes; 129 return devicetypes;
122 } 130 }
123 131
124 // Get list of devices, runtimes, etc from sim_ctl. 132 // Get list of devices, runtimes, etc from sim_ctl.
125 NSDictionary* GetSimulatorList() { 133 NSDictionary* GetSimulatorList() {
126 XCRunTask* task = [[[XCRunTask alloc] 134 XCRunTask* task = [[[XCRunTask alloc]
127 initWithArguments:@[ @"simctl", @"list", @"-j" ]] autorelease]; 135 initWithArguments:@[ @"simctl", @"list", @"-j" ]] autorelease];
128 NSPipe* out = [NSPipe pipe]; 136 NSPipe* out = [NSPipe pipe];
129 [task setStandardOutput:out]; 137 [task setStandardOutput:out];
130 [task run];
131 138
139 [task launch];
132 NSData* data = [[out fileHandleForReading] readDataToEndOfFile]; 140 NSData* data = [[out fileHandleForReading] readDataToEndOfFile];
rohitrao (ping after 24h) 2016/08/13 00:59:05 Add a comment explaining why the code is ordered t
141 [task waitUntilExit];
142
133 NSError* error = nil; 143 NSError* error = nil;
134 return [NSJSONSerialization JSONObjectWithData:data 144 return [NSJSONSerialization JSONObjectWithData:data
135 options:kNilOptions 145 options:kNilOptions
136 error:&error]; 146 error:&error];
137 } 147 }
138 148
139 // List supported runtimes and devices. 149 // List supported runtimes and devices.
140 void PrintSupportedDevices(NSDictionary* simctl_list) { 150 void PrintSupportedDevices(NSDictionary* simctl_list) {
141 printf("\niOS devices:\n"); 151 printf("\niOS devices:\n");
142 for (NSDictionary* type in Devices(simctl_list)) { 152 for (NSDictionary* type in Devices(simctl_list)) {
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1268 }
1259 1269
1260 // Note that this code is only executed if the simulator fails to start 1270 // Note that this code is only executed if the simulator fails to start
1261 // because once the main run loop is started, only the delegate calling 1271 // because once the main run loop is started, only the delegate calling
1262 // exit() will end the program. 1272 // exit() will end the program.
1263 [pool drain]; 1273 [pool drain];
1264 return kExitFailure; 1274 return kExitFailure;
1265 } 1275 }
1266 1276
1267 #endif 1277 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698