@@ -16,7 +16,11 @@ const PROVISIONING_FAILURE_STDERR = [
1616 '** TEST EXECUTE FAILED **' ,
1717] . join ( '\n' ) ;
1818
19- function sessionFailingWith ( stdout : string , stderr : string ) : RunnerSession {
19+ function sessionFailingWith (
20+ stdout : string ,
21+ stderr : string ,
22+ startupDeviceStates ?: RunnerSession [ 'startupDeviceStates' ] ,
23+ ) : RunnerSession {
2024 return {
2125 sessionId : 'early-exit-session' ,
2226 device : { platform : 'apple' , id : 'device-1' , name : 'iPhone' , kind : 'device' , booted : true } ,
@@ -27,9 +31,16 @@ function sessionFailingWith(stdout: string, stderr: string): RunnerSession {
2731 testPromise : Promise . resolve ( { exitCode : 1 , stdout, stderr } ) ,
2832 child : { pid : 4242 , exitCode : 1 } as ExecBackgroundResult [ 'child' ] ,
2933 state : 'starting' ,
34+ startupDeviceStates,
3035 } ;
3136}
3237
38+ const IMAGE_DOWN_STATES = {
39+ developerMode : 'enabled' as const ,
40+ developerDiskImage : 'unavailable' as const ,
41+ developerDiskImageHint : 'Unlock the iPhone so it can mount the developer disk image.' ,
42+ } ;
43+
3344test ( 'the early-exit error a user actually receives names the provisioning cause' , async ( ) => {
3445 // Regression: the reason was classified correctly while the hint was built
3546 // separately and always returned connect-timeout guidance, so the shipped
@@ -67,3 +78,44 @@ test('a busy connecting device keeps its own targeted hint', async () => {
6778
6879 assert . match ( String ( error . details ?. hint ) , / s t i l l c o n n e c t i n g / ) ;
6980} ) ;
81+
82+ test ( 'an early exit carries the disk-image state the device was read in (#2683)' , async ( ) => {
83+ // A locked iPhone lets the build finish and kills `xcodebuild test-without-building` instead, so
84+ // the startup build catch never runs and the readiness facts read before the build would be
85+ // dropped. Captured on hardware: this is the failure an image-down locked phone actually produces.
86+ const error = ( await buildRunnerEarlyExitError ( {
87+ session : sessionFailingWith (
88+ '' ,
89+ 'xcodebuild: error: Timed out waiting for the test runner' ,
90+ IMAGE_DOWN_STATES ,
91+ ) ,
92+ port : 8100 ,
93+ } ) ) as AppError ;
94+
95+ assert . equal ( error . details ?. developerDiskImage , 'unavailable' ) ;
96+ } ) ;
97+
98+ test ( 'an early exit that already names a cause keeps it, and only gains the fact (#2683)' , async ( ) => {
99+ const error = ( await buildRunnerEarlyExitError ( {
100+ session : sessionFailingWith (
101+ '' ,
102+ 'xcodebuild: error: Timed out waiting for the test runner' ,
103+ IMAGE_DOWN_STATES ,
104+ ) ,
105+ port : 8100 ,
106+ } ) ) as AppError ;
107+
108+ // The connect reason was proved by the tool output, so the device's image state is never allowed
109+ // to overwrite a claimed cause or swap the hint beside it.
110+ assert . equal ( error . details ?. reason , 'IOS_RUNNER_CONNECT_TIMEOUT' ) ;
111+ assert . match ( String ( error . details ?. hint ) , / R e t r y r u n n e r s t a r t u p / ) ;
112+ } ) ;
113+
114+ test ( 'a session that never probed the device publishes no disk-image claim (#2683)' , async ( ) => {
115+ const error = ( await buildRunnerEarlyExitError ( {
116+ session : sessionFailingWith ( '' , 'xcodebuild: error: Timed out waiting for the test runner' ) ,
117+ port : 8100 ,
118+ } ) ) as AppError ;
119+
120+ assert . equal ( 'developerDiskImage' in ( error . details ?? { } ) , false ) ;
121+ } ) ;
0 commit comments