watchOS Simulator: Can’t Retrieve Exit Status of WatchKit Extension from Command Line

Originator:SlaunchaMan
Number:rdar://30201876 Date Originated:25-Jan-2017 10:43 PM
Status:Closed Resolved:Closed
Product:watchOS + SDK Product Version:watchOS Simulator 3.2 (14V5205c)
Classification:Other Bug Reproducible:Always
 
Summary:
I have a WatchKit Extension that runs tests using a locally-compiled version of XCTest. Since it uses XCTest’s XCTMain() to run the tests, the extension calls exit(1) when it exits with a failing test. Unfortunately, there seems to be no way to retrieve this exit status from the command line to integrate these watchOS tests into a continuous integration workflow, nor is there a way to retrieve the stdout/stderr from the extension to parse the results into something like a JUnit test report.

Steps to Reproduce:
1. Install a watch app on a watch simulator.
2. Use simctl to launch the app from the command line using:
  2a. the --console flag
  2b. the --stdout and --stderr flags

Expected Results:
The exit status of the simctl command will be the exit status of the extension.

2a: The program output will appear in the command line.
2b: The program output will appear in the specified path(s).

Actual Results:
Program output is seen, but is limited to a single message from the OS. The exit status is always 0.

Version:
Xcode Version 8.3 beta (8W109m)
watchOS Simulator 3.2 (14V5205c)

Notes:
The following is Terminal output from attempting this.

zuvio:WatchTests jeff$ xcode-select --print-path
/Applications/Xcode-beta.app/Contents/Developer
zuvio:WatchTests jeff$ xcrun simctl launch --console 8CBE8A2C-3B4C-48A0-B596-24D18AF4A950 com.detroitlabs.WatchTests.watchkitapp
com.detroitlabs.WatchTests.watchkitapp: 1081
2017-01-25 22:30:21.144 WatchTestsTestRunner WatchKit App[1081:44717] Snapshotting a view that has not been rendered results in an empty snapshot. Ensure your view has been rendered at least once before snapshotting or snapshot after screen updates.
zuvio:WatchTests jeff$ echo $?
0
zuvio:WatchTests jeff$ xcrun simctl launch --stdout=/Users/jeff/Desktop/testout.txt --stderr=/Users/jeff/Desktop/testerr.txt 8CBE8A2C-3B4C-48A0-B596-24D18AF4A950 com.detroitlabs.WatchTests.watchkitapp
com.detroitlabs.WatchTests.watchkitapp: 1089
zuvio:WatchTests jeff$

Comments

Response from Apple

March 7 2017, 3:49 PM Please know that our engineering team has determined that this issue behaves as intended based on the information provided.

By SlaunchaMan at Aug. 15, 2018, 3:37 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!