-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
xcuitestrunner.go
531 lines (461 loc) · 19.5 KB
/
xcuitestrunner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
package testmanagerd
import (
"context"
"fmt"
"github.com/danielpaulus/go-ios/ios/house_arrest"
"path"
"strings"
"time"
"github.com/danielpaulus/go-ios/ios"
dtx "github.com/danielpaulus/go-ios/ios/dtx_codec"
"github.com/danielpaulus/go-ios/ios/installationproxy"
"github.com/danielpaulus/go-ios/ios/instruments"
"github.com/danielpaulus/go-ios/ios/nskeyedarchiver"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
type XCTestManager_IDEInterface struct {
IDEDaemonProxy *dtx.Channel
testBundleReadyChannel chan dtx.Message
testConfig nskeyedarchiver.XCTestConfiguration
}
type XCTestManager_DaemonConnectionInterface struct {
IDEDaemonProxy *dtx.Channel
}
func (xide XCTestManager_IDEInterface) testBundleReady() (uint64, uint64) {
msg := <-xide.testBundleReadyChannel
protocolVersion, _ := nskeyedarchiver.Unarchive(msg.Auxiliary.GetArguments()[0].([]byte))
minimalVersion, _ := nskeyedarchiver.Unarchive(msg.Auxiliary.GetArguments()[1].([]byte))
return protocolVersion[0].(uint64), minimalVersion[0].(uint64)
}
func testRunnerReadyWithCapabilitiesConfig(testConfig nskeyedarchiver.XCTestConfiguration) dtx.MethodWithResponse {
return func(msg dtx.Message) (interface{}, error) {
//protocolVersion, _ := nskeyedarchiver.Unarchive(msg.Auxiliary.GetArguments()[0].([]byte))
//nskeyedarchiver.XCTCapabilities
response := testConfig
//caps := protocolVersion[0].(nskeyedarchiver.XCTCapabilities)
return response, nil
}
}
func (xdc XCTestManager_DaemonConnectionInterface) startExecutingTestPlanWithProtocolVersion(channel *dtx.Channel, version uint64) error {
return channel.MethodCallAsync("_IDE_startExecutingTestPlanWithProtocolVersion:", version)
}
func (xdc XCTestManager_DaemonConnectionInterface) authorizeTestSessionWithProcessID(pid uint64) (bool, error) {
rply, err := xdc.IDEDaemonProxy.MethodCall("_IDE_authorizeTestSessionWithProcessID:", pid)
if err != nil {
log.Errorf("authorizeTestSessionWithProcessID failed: %v, err:%v", pid, err)
return false, err
}
returnValue := rply.Payload[0]
var val bool
var ok bool
if val, ok = returnValue.(bool); !ok {
return val, fmt.Errorf("_IDE_authorizeTestSessionWithProcessID: got wrong returnvalue: %s", rply.Payload)
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("_IDE_authorizeTestSessionWithProcessID: reply")
return val, err
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateSessionWithIdentifierAndCaps(uuid uuid.UUID, caps nskeyedarchiver.XCTCapabilities) (nskeyedarchiver.XCTCapabilities, error) {
var val nskeyedarchiver.XCTCapabilities
var ok bool
rply, err := xdc.IDEDaemonProxy.MethodCall("_IDE_initiateSessionWithIdentifier:capabilities:", nskeyedarchiver.NewNSUUID(uuid), caps)
if err != nil {
log.Errorf("initiateSessionWithIdentifierAndCaps failed: %v", err)
return val, err
}
returnValue := rply.Payload[0]
if val, ok = returnValue.(nskeyedarchiver.XCTCapabilities); !ok {
return val, fmt.Errorf("_IDE_initiateSessionWithIdentifier:capabilities: got wrong returnvalue: %s", rply.Payload)
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("_IDE_initiateSessionWithIdentifier:capabilities: reply")
return val, err
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateControlSessionWithCapabilities(caps nskeyedarchiver.XCTCapabilities) (nskeyedarchiver.XCTCapabilities, error) {
var val nskeyedarchiver.XCTCapabilities
var ok bool
rply, err := xdc.IDEDaemonProxy.MethodCall("_IDE_initiateControlSessionWithCapabilities:", caps)
if err != nil {
log.Errorf("initiateControlSessionWithCapabilities failed: %v", err)
return val, err
}
returnValue := rply.Payload[0]
if val, ok = returnValue.(nskeyedarchiver.XCTCapabilities); !ok {
return val, fmt.Errorf("_IDE_initiateControlSessionWithCapabilities got wrong returnvalue: %s", rply.Payload)
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("_IDE_initiateControlSessionWithCapabilities reply")
return val, err
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateSessionWithIdentifier(sessionIdentifier uuid.UUID, protocolVersion uint64) (uint64, error) {
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName}).Debug("Launching init test Session")
var val uint64
var ok bool
rply, err := xdc.IDEDaemonProxy.MethodCall(
"_IDE_initiateSessionWithIdentifier:forClient:atPath:protocolVersion:",
nskeyedarchiver.NewNSUUID(sessionIdentifier),
"thephonedoesntcarewhatisendhereitseems",
"/Applications/Xcode.app",
protocolVersion)
if err != nil {
log.Errorf("initiateSessionWithIdentifier failed: %v", err)
return val, err
}
returnValue := rply.Payload[0]
if val, ok = returnValue.(uint64); !ok {
return 0, fmt.Errorf("initiateSessionWithIdentifier got wrong returnvalue: %s", rply.Payload)
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("init test session reply")
return val, err
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateControlSessionForTestProcessID(pid uint64, protocolVersion uint64) error {
rply, err := xdc.IDEDaemonProxy.MethodCall("_IDE_initiateControlSessionForTestProcessID:protocolVersion:", pid, protocolVersion)
if err != nil {
return err
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("initiateControlSessionForTestProcessID reply")
return nil
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateControlSessionWithProtocolVersion(protocolVersion uint64) (uint64, error) {
rply, err := xdc.IDEDaemonProxy.MethodCall("_IDE_initiateControlSessionWithProtocolVersion:", protocolVersion)
if err != nil {
return 0, err
}
returnValue := rply.Payload[0]
var val uint64
var ok bool
if val, ok = returnValue.(uint64); !ok {
return val, fmt.Errorf("_IDE_initiateControlSessionWithProtocolVersion got wrong returnvalue: %s", rply.Payload)
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("initiateControlSessionForTestProcessID reply")
return val, nil
}
func (xdc XCTestManager_DaemonConnectionInterface) initiateControlSession(pid uint64, version uint64) error {
_, err := xdc.IDEDaemonProxy.MethodCall("_IDE_initiateControlSessionForTestProcessID:protocolVersion:", pid, version)
return err
}
func startExecutingTestPlanWithProtocolVersion(channel *dtx.Channel, protocolVersion uint64) error {
rply, err := channel.MethodCall("_IDE_startExecutingTestPlanWithProtocolVersion:", protocolVersion)
if err != nil {
return err
}
log.WithFields(log.Fields{"channel_id": ideToDaemonProxyChannelName, "reply": rply}).Debug("_IDE_startExecutingTestPlanWithProtocolVersion reply")
return nil
}
const ideToDaemonProxyChannelName = "dtxproxy:XCTestManager_IDEInterface:XCTestManager_DaemonConnectionInterface"
type dtxproxy struct {
ideInterface XCTestManager_IDEInterface
daemonConnection XCTestManager_DaemonConnectionInterface
IDEDaemonProxy *dtx.Channel
dtxConnection *dtx.Connection
proxyDispatcher ProxyDispatcher
}
type ProxyDispatcher struct {
testBundleReadyChannel chan dtx.Message
testRunnerReadyWithCapabilities dtx.MethodWithResponse
dtxConnection *dtx.Connection
id string
}
func (p ProxyDispatcher) Dispatch(m dtx.Message) {
shouldAck := true
if len(m.Payload) == 1 {
method := m.Payload[0].(string)
switch method {
case "_XCT_testBundleReadyWithProtocolVersion:minimumVersion:":
p.testBundleReadyChannel <- m
return
case "_XCT_logDebugMessage:":
mbytes := m.Auxiliary.GetArguments()[0].([]byte)
data, _ := nskeyedarchiver.Unarchive(mbytes)
log.Debug(data)
case "_XCT_testRunnerReadyWithCapabilities:":
shouldAck = false
log.Debug("received testRunnerReadyWithCapabilities")
resp, _ := p.testRunnerReadyWithCapabilities(m)
payload, _ := nskeyedarchiver.ArchiveBin(resp)
messageBytes, _ := dtx.Encode(m.Identifier, 1, m.ChannelCode, false, dtx.ResponseWithReturnValueInPayload, payload, dtx.NewPrimitiveDictionary())
log.Debug("sending response for capabs")
p.dtxConnection.Send(messageBytes)
case "_XCT_didFinishExecutingTestPlan":
log.Info("_XCT_didFinishExecutingTestPlan received. Closing test.")
CloseXCUITestRunner()
default:
log.WithFields(log.Fields{"sel": method}).Infof("device called local method")
}
}
if shouldAck {
dtx.SendAckIfNeeded(p.dtxConnection, m)
}
log.Tracef("dispatcher received: %s", m.String())
}
func newDtxProxy(dtxConnection *dtx.Connection) dtxproxy {
testBundleReadyChannel := make(chan dtx.Message, 1)
//(xide XCTestManager_IDEInterface)
proxyDispatcher := ProxyDispatcher{testBundleReadyChannel: testBundleReadyChannel, dtxConnection: dtxConnection}
IDEDaemonProxy := dtxConnection.RequestChannelIdentifier(ideToDaemonProxyChannelName, proxyDispatcher)
ideInterface := XCTestManager_IDEInterface{IDEDaemonProxy: IDEDaemonProxy, testBundleReadyChannel: testBundleReadyChannel}
return dtxproxy{IDEDaemonProxy: IDEDaemonProxy,
ideInterface: ideInterface,
daemonConnection: XCTestManager_DaemonConnectionInterface{IDEDaemonProxy},
dtxConnection: dtxConnection,
proxyDispatcher: proxyDispatcher,
}
}
func newDtxProxyWithConfig(dtxConnection *dtx.Connection, testConfig nskeyedarchiver.XCTestConfiguration) dtxproxy {
testBundleReadyChannel := make(chan dtx.Message, 1)
//(xide XCTestManager_IDEInterface)
proxyDispatcher := ProxyDispatcher{testBundleReadyChannel: testBundleReadyChannel, dtxConnection: dtxConnection, testRunnerReadyWithCapabilities: testRunnerReadyWithCapabilitiesConfig(testConfig)}
IDEDaemonProxy := dtxConnection.RequestChannelIdentifier(ideToDaemonProxyChannelName, proxyDispatcher)
ideInterface := XCTestManager_IDEInterface{IDEDaemonProxy: IDEDaemonProxy, testConfig: testConfig, testBundleReadyChannel: testBundleReadyChannel}
return dtxproxy{IDEDaemonProxy: IDEDaemonProxy,
ideInterface: ideInterface,
daemonConnection: XCTestManager_DaemonConnectionInterface{IDEDaemonProxy},
dtxConnection: dtxConnection,
proxyDispatcher: proxyDispatcher,
}
}
const testmanagerd = "com.apple.testmanagerd.lockdown"
const testmanagerdiOS14 = "com.apple.testmanagerd.lockdown.secure"
const testBundleSuffix = "UITests.xctrunner"
func RunXCUITest(bundleID string, device ios.DeviceEntry, env []string) error {
testRunnerBundleID := bundleID + testBundleSuffix
//FIXME: this is redundant code, getting the app list twice and creating the appinfos twice
//just to generate the xctestConfigFileName. Should be cleaned up at some point.
installationProxy, err := installationproxy.New(device)
if err != nil {
return err
}
defer installationProxy.Close()
apps, err := installationProxy.BrowseUserApps()
if err != nil {
return err
}
info, err := getAppInfos(bundleID, testRunnerBundleID, apps)
if err != nil {
return err
}
xctestConfigFileName := info.targetAppBundleName + "UITests.xctest"
return RunXCUIWithBundleIdsCtx(nil, bundleID, testRunnerBundleID, xctestConfigFileName, device, nil, env)
}
var closeChan = make(chan interface{})
var closedChan = make(chan interface{})
func runXUITestWithBundleIdsXcode12Ctx(ctx context.Context, bundleID string, testRunnerBundleID string, xctestConfigFileName string,
device ios.DeviceEntry, conn *dtx.Connection, args []string, env []string) error {
testSessionId, xctestConfigPath, testConfig, testInfo, err := setupXcuiTest(device, bundleID, testRunnerBundleID, xctestConfigFileName)
if err != nil {
return err
}
defer conn.Close()
ideDaemonProxy := newDtxProxyWithConfig(conn, testConfig)
conn2, err := dtx.NewConnection(device, testmanagerdiOS14)
if err != nil {
return err
}
defer conn2.Close()
log.Debug("connections ready")
ideDaemonProxy2 := newDtxProxyWithConfig(conn2, testConfig)
ideDaemonProxy2.ideInterface.testConfig = testConfig
caps, err := ideDaemonProxy.daemonConnection.initiateControlSessionWithCapabilities(nskeyedarchiver.XCTCapabilities{})
if err != nil {
return err
}
log.Debug(caps)
localCaps := nskeyedarchiver.XCTCapabilities{CapabilitiesDictionary: map[string]interface{}{
"XCTIssue capability": uint64(1),
"skipped test capability": uint64(1),
"test timeout capability": uint64(1),
}}
caps2, err := ideDaemonProxy2.daemonConnection.initiateSessionWithIdentifierAndCaps(testSessionId, localCaps)
if err != nil {
return err
}
log.Debug(caps2)
pControl, err := instruments.NewProcessControl(device)
if err != nil {
return err
}
defer pControl.Close()
pid, err := startTestRunner12(pControl, xctestConfigPath, testRunnerBundleID, testSessionId.String(), testInfo.testrunnerAppPath+"/PlugIns/"+xctestConfigFileName, args, env)
if err != nil {
return err
}
log.Debugf("Runner started with pid:%d, waiting for testBundleReady", pid)
ideInterfaceChannel := ideDaemonProxy2.dtxConnection.ForChannelRequest(ProxyDispatcher{id: "emty"})
time.Sleep(time.Second)
success, _ := ideDaemonProxy.daemonConnection.authorizeTestSessionWithProcessID(pid)
log.Debugf("authorizing test session for pid %d successful %t", pid, success)
err = ideDaemonProxy2.daemonConnection.startExecutingTestPlanWithProtocolVersion(ideInterfaceChannel, 36)
if err != nil {
log.Error(err)
return err
}
if ctx != nil {
select {
case <-ctx.Done():
log.Infof("Killing WebDriverAgent with pid %d ...", pid)
err = pControl.KillProcess(pid)
if err != nil {
return err
}
log.Info("WDA killed with success")
}
return nil
}
<-closeChan
log.Infof("Killing UITest with pid %d ...", pid)
err = pControl.KillProcess(pid)
if err != nil {
return err
}
log.Info("WDA killed with success")
var signal interface{}
closedChan <- signal
return nil
}
func RunXCUIWithBundleIdsCtx(
ctx context.Context,
bundleID string,
testRunnerBundleID string,
xctestConfigFileName string,
device ios.DeviceEntry,
wdaargs []string,
wdaenv []string,
) error {
version, err := ios.GetProductVersion(device)
if err != nil {
return err
}
log.Debugf("%v", version)
if version.LessThan(ios.IOS14()) {
log.Infof("iOS version: %s detected, running with ios11 support", version)
return RunXCUIWithBundleIds11Ctx(ctx, bundleID, testRunnerBundleID, xctestConfigFileName, device, wdaargs, wdaenv)
}
conn, err := dtx.NewConnection(device, testmanagerdiOS14)
if err != nil {
return err
}
return runXUITestWithBundleIdsXcode12Ctx(ctx, bundleID, testRunnerBundleID, xctestConfigFileName, device, conn, wdaargs, wdaenv)
}
func CloseXCUITestRunner() error {
var signal interface{}
go func() { closeChan <- signal }()
select {
case <-closedChan:
return nil
case <-time.After(5 * time.Second):
return fmt.Errorf("Failed closing, exiting due to timeout")
}
}
func startTestRunner(pControl *instruments.ProcessControl, xctestConfigPath string, bundleID string) (uint64, error) {
args := []interface{}{}
env := map[string]interface{}{
"XCTestConfigurationFilePath": xctestConfigPath,
}
opts := map[string]interface{}{
"StartSuspendedKey": uint64(0),
"ActivateSuspended": uint64(1),
}
return pControl.StartProcess(bundleID, env, args, opts)
}
func startTestRunner12(pControl *instruments.ProcessControl, xctestConfigPath string, bundleID string,
sessionIdentifier string, testBundlePath string, wdaargs []string, wdaenv []string) (uint64, error) {
args := []interface{}{
"-NSTreatUnknownArgumentsAsOpen", "NO", "-ApplePersistenceIgnoreState", "YES",
}
for _, arg := range wdaargs {
args = append(args, arg)
}
env := map[string]interface{}{
"CA_ASSERT_MAIN_THREAD_TRANSACTIONS": "0",
"CA_DEBUG_TRANSACTIONS": "0",
"DYLD_INSERT_LIBRARIES": "/Developer/usr/lib/libMainThreadChecker.dylib",
"MTC_CRASH_ON_REPORT": "1",
"NSUnbufferedIO": "YES",
"OS_ACTIVITY_DT_MODE": "YES",
"SQLITE_ENABLE_THREAD_ASSERTIONS": "1",
"XCTestBundlePath": testBundlePath,
"XCTestConfigurationFilePath": xctestConfigPath,
"XCTestSessionIdentifier": sessionIdentifier,
}
for _, entrystring := range wdaenv {
entry := strings.Split(entrystring, "=")
key := entry[0]
value := entry[1]
env[key] = value
log.Debugf("adding extra env %s=%s", key, value)
}
opts := map[string]interface{}{
"StartSuspendedKey": uint64(0),
"ActivateSuspended": uint64(1),
}
return pControl.StartProcess(bundleID, env, args, opts)
}
func setupXcuiTest(device ios.DeviceEntry, bundleID string, testRunnerBundleID string, xctestConfigFileName string) (uuid.UUID, string, nskeyedarchiver.XCTestConfiguration, testInfo, error) {
testSessionID := uuid.New()
installationProxy, err := installationproxy.New(device)
if err != nil {
return uuid.UUID{}, "", nskeyedarchiver.XCTestConfiguration{}, testInfo{}, err
}
defer installationProxy.Close()
apps, err := installationProxy.BrowseUserApps()
if err != nil {
return uuid.UUID{}, "", nskeyedarchiver.XCTestConfiguration{}, testInfo{}, err
}
info, err := getAppInfos(bundleID, testRunnerBundleID, apps)
if err != nil {
return uuid.UUID{}, "", nskeyedarchiver.XCTestConfiguration{}, testInfo{}, err
}
log.Debugf("app info found: %+v", info)
houseArrestService, err := house_arrest.New(device, testRunnerBundleID)
defer houseArrestService.Close()
if err != nil {
return uuid.UUID{}, "", nskeyedarchiver.XCTestConfiguration{}, testInfo{}, err
}
log.Debugf("creating test config")
testConfigPath, testConfig, err := createTestConfigOnDevice(testSessionID, info, houseArrestService, xctestConfigFileName)
if err != nil {
return uuid.UUID{}, "", nskeyedarchiver.XCTestConfiguration{}, testInfo{}, err
}
return testSessionID, testConfigPath, testConfig, info, nil
}
func createTestConfigOnDevice(testSessionID uuid.UUID, info testInfo, houseArrestService *house_arrest.Connection, xctestConfigFileName string) (string, nskeyedarchiver.XCTestConfiguration, error) {
relativeXcTestConfigPath := path.Join("tmp", testSessionID.String()+".xctestconfiguration")
xctestConfigPath := path.Join(info.testRunnerHomePath, relativeXcTestConfigPath)
testBundleURL := path.Join(info.testrunnerAppPath, "PlugIns", xctestConfigFileName)
config := nskeyedarchiver.NewXCTestConfiguration(info.targetAppBundleName, testSessionID, info.targetAppBundleID, info.targetAppPath, testBundleURL)
result, err := nskeyedarchiver.ArchiveXML(config)
if err != nil {
return "", nskeyedarchiver.XCTestConfiguration{}, err
}
err = houseArrestService.SendFile([]byte(result), relativeXcTestConfigPath)
if err != nil {
return "", nskeyedarchiver.XCTestConfiguration{}, err
}
return xctestConfigPath, nskeyedarchiver.NewXCTestConfiguration(info.targetAppBundleName, testSessionID, info.targetAppBundleID, info.targetAppPath, testBundleURL), nil
}
type testInfo struct {
testrunnerAppPath string
testRunnerHomePath string
targetAppPath string
targetAppBundleName string
targetAppBundleID string
}
func getAppInfos(bundleID string, testRunnerBundleID string, apps []installationproxy.AppInfo) (testInfo, error) {
info := testInfo{}
for _, app := range apps {
if app.CFBundleIdentifier == bundleID {
info.targetAppPath = app.Path
info.targetAppBundleName = app.CFBundleName
info.targetAppBundleID = app.CFBundleIdentifier
}
if app.CFBundleIdentifier == testRunnerBundleID {
info.testrunnerAppPath = app.Path
info.testRunnerHomePath = app.EnvironmentVariables["HOME"].(string)
}
}
if info.targetAppPath == "" {
return testInfo{}, fmt.Errorf("Did not find AppInfo for '%s' on device. Is it installed?", bundleID)
}
if info.testRunnerHomePath == "" || info.testrunnerAppPath == "" {
return testInfo{}, fmt.Errorf("Did not find AppInfo for '%s' on device. Is it installed?", testRunnerBundleID)
}
return info, nil
}