OLD | NEW |
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 sdk_version); | 329 sdk_version); |
330 PrintSupportedDevices(simctl_list); | 330 PrintSupportedDevices(simctl_list); |
331 exit(kExitInvalidArguments); | 331 exit(kExitInvalidArguments); |
332 } | 332 } |
333 | 333 |
334 if (wants_print_home) { | 334 if (wants_print_home) { |
335 PrintDeviceHome(udid); | 335 PrintDeviceHome(udid); |
336 exit(kExitSuccess); | 336 exit(kExitSuccess); |
337 } | 337 } |
338 | 338 |
| 339 KillSimulator(); |
| 340 if (wants_wipe) { |
| 341 WipeDevice(udid); |
| 342 printf("Device wiped.\n"); |
| 343 exit(kExitSuccess); |
| 344 } |
| 345 |
339 // There should be at least one arg left, specifying the app path. Any | 346 // There should be at least one arg left, specifying the app path. Any |
340 // additional args are passed as arguments to the app. | 347 // additional args are passed as arguments to the app. |
341 if (optind < argc) { | 348 if (optind < argc) { |
342 NSString* unresolved_path = [[NSFileManager defaultManager] | 349 NSString* unresolved_path = [[NSFileManager defaultManager] |
343 stringWithFileSystemRepresentation:argv[optind] | 350 stringWithFileSystemRepresentation:argv[optind] |
344 length:strlen(argv[optind])]; | 351 length:strlen(argv[optind])]; |
345 app_path = ResolvePath(unresolved_path); | 352 app_path = ResolvePath(unresolved_path); |
346 if (!app_path) { | 353 if (!app_path) { |
347 LogError(@"Unable to resolve app_path %@", unresolved_path); | 354 LogError(@"Unable to resolve app_path %@", unresolved_path); |
348 exit(kExitInvalidArguments); | 355 exit(kExitInvalidArguments); |
349 } | 356 } |
350 | 357 |
351 if (++optind < argc) { | 358 if (++optind < argc) { |
352 NSString* unresolved_path = [[NSFileManager defaultManager] | 359 NSString* unresolved_path = [[NSFileManager defaultManager] |
353 stringWithFileSystemRepresentation:argv[optind] | 360 stringWithFileSystemRepresentation:argv[optind] |
354 length:strlen(argv[optind])]; | 361 length:strlen(argv[optind])]; |
355 xctest_path = ResolvePath(unresolved_path); | 362 xctest_path = ResolvePath(unresolved_path); |
356 if (!xctest_path) { | 363 if (!xctest_path) { |
357 LogError(@"Unable to resolve xctest_path %@", unresolved_path); | 364 LogError(@"Unable to resolve xctest_path %@", unresolved_path); |
358 exit(kExitInvalidArguments); | 365 exit(kExitInvalidArguments); |
359 } | 366 } |
360 } | 367 } |
361 } else { | 368 } else { |
362 LogError(@"Unable to parse command line arguments."); | 369 LogError(@"Unable to parse command line arguments."); |
363 PrintUsage(); | 370 PrintUsage(); |
364 exit(kExitInvalidArguments); | 371 exit(kExitInvalidArguments); |
365 } | 372 } |
366 | 373 |
367 KillSimulator(); | |
368 if (wants_wipe) { | |
369 WipeDevice(udid); | |
370 } | |
371 | |
372 RunApplication(app_path, xctest_path, udid, app_env, cmd_args); | 374 RunApplication(app_path, xctest_path, udid, app_env, cmd_args); |
373 KillSimulator(); | 375 KillSimulator(); |
374 return kExitSuccess; | 376 return kExitSuccess; |
375 } | 377 } |
376 #else | 378 #else |
377 #import <Appkit/Appkit.h> | 379 #import <Appkit/Appkit.h> |
378 #include <asl.h> | 380 #include <asl.h> |
379 #import <Foundation/Foundation.h> | 381 #import <Foundation/Foundation.h> |
380 #include <libgen.h> | 382 #include <libgen.h> |
381 #include <stdarg.h> | 383 #include <stdarg.h> |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 } | 1236 } |
1235 | 1237 |
1236 // Note that this code is only executed if the simulator fails to start | 1238 // Note that this code is only executed if the simulator fails to start |
1237 // because once the main run loop is started, only the delegate calling | 1239 // because once the main run loop is started, only the delegate calling |
1238 // exit() will end the program. | 1240 // exit() will end the program. |
1239 [pool drain]; | 1241 [pool drain]; |
1240 return kExitFailure; | 1242 return kExitFailure; |
1241 } | 1243 } |
1242 | 1244 |
1243 #endif | 1245 #endif |
OLD | NEW |