@@ -289,35 +289,11 @@ func runXUITestWithBundleIdsXcode15Ctx(
289289 }
290290 defer conn2 .Close ()
291291
292- installationProxy , err := installationproxy .New (config .Device )
293- if err != nil {
294- return make ([]TestSuite , 0 ), fmt .Errorf ("runXUITestWithBundleIdsXcode15Ctx: cannot connect to installation proxy: %w" , err )
295- }
296- defer installationProxy .Close ()
297- apps , err := installationProxy .BrowseUserApps ()
298- if err != nil {
299- return make ([]TestSuite , 0 ), fmt .Errorf ("runXUITestWithBundleIdsXcode15Ctx: cannot browse user apps: %w" , err )
300- }
301-
302- testAppInfo , err := getappInfo (config .TestRunnerBundleId , apps )
292+ testSessionID := uuid .New ()
293+ info , err := getTestInfo (config .Device , config .BundleId , config .TestRunnerBundleId )
303294 if err != nil {
304- return make ([]TestSuite , 0 ), fmt .Errorf ("runXUITestWithBundleIdsXcode15Ctx: cannot get test app information : %w" , err )
295+ return make ([]TestSuite , 0 ), fmt .Errorf ("runXUITestWithBundleIdsXcode15Ctx: cannot build test info : %w" , err )
305296 }
306-
307- info := testInfo {
308- testApp : testAppInfo ,
309- }
310-
311- if config .BundleId != "" {
312- appInfo , err := getappInfo (config .BundleId , apps )
313- if err != nil {
314- return make ([]TestSuite , 0 ), fmt .Errorf ("runXUITestWithBundleIdsXcode15Ctx: cannot get app information: %w" , err )
315- }
316-
317- info .targetApp = appInfo
318- }
319-
320- testSessionID := uuid .New ()
321297 testconfig := createTestConfig (info , testSessionID , config .XctestConfigName , config .TestsToRun , config .TestsToSkip , config .XcTest , version )
322298 ideDaemonProxy1 := newDtxProxyWithConfig (conn1 , testconfig , config .Listener )
323299
@@ -483,22 +459,21 @@ func startTestRunner17(appserviceConn *appservice.Connection, bundleID string, s
483459 return appLaunch , nil
484460}
485461
486- func setupXcuiTest (device ios.DeviceEntry , bundleID string , testRunnerBundleID string , xctestConfigFileName string , testsToRun []string , testsToSkip []string , isXCTest bool , version * semver.Version ) (uuid.UUID , string , nskeyedarchiver.XCTestConfiguration , testInfo , error ) {
487- testSessionID := uuid .New ()
462+ func getTestInfo (device ios.DeviceEntry , bundleID string , testRunnerBundleID string ) (testInfo , error ) {
488463 installationProxy , err := installationproxy .New (device )
489464 if err != nil {
490- return uuid. UUID {}, "" , nskeyedarchiver. XCTestConfiguration {}, testInfo {} , err
465+ return testInfo {}, fmt . Errorf ( "cannot connect to installation proxy: %w" , err )
491466 }
492467 defer installationProxy .Close ()
493468
494469 apps , err := installationProxy .BrowseUserApps ()
495470 if err != nil {
496- return uuid. UUID {}, "" , nskeyedarchiver. XCTestConfiguration {}, testInfo {} , err
471+ return testInfo {}, fmt . Errorf ( "cannot browse user apps: %w" , err )
497472 }
498473
499474 testAppInfo , err := getappInfo (testRunnerBundleID , apps )
500475 if err != nil {
501- return uuid. UUID {}, "" , nskeyedarchiver. XCTestConfiguration {}, testInfo {} , err
476+ return testInfo {}, fmt . Errorf ( "cannot get test app information: %w" , err )
502477 }
503478
504479 info := testInfo {
@@ -508,19 +483,32 @@ func setupXcuiTest(device ios.DeviceEntry, bundleID string, testRunnerBundleID s
508483 if bundleID != "" {
509484 appInfo , err := getappInfo (bundleID , apps )
510485 if err != nil {
511- return uuid. UUID {}, "" , nskeyedarchiver. XCTestConfiguration {}, testInfo {} , err
486+ return testInfo {}, fmt . Errorf ( "cannot get app information: %w" , err )
512487 }
513488 log .Debugf ("app info found: %+v" , appInfo )
514489
515490 info .targetApp = appInfo
516491 }
517492
493+ return info , nil
494+ }
495+
496+ func setupXcuiTest (device ios.DeviceEntry , bundleID string , testRunnerBundleID string , xctestConfigFileName string , testsToRun []string ,
497+ testsToSkip []string , isXCTest bool , version * semver.Version ,
498+ ) (uuid.UUID , string , nskeyedarchiver.XCTestConfiguration , testInfo , error ) {
499+ info , err := getTestInfo (device , bundleID , testRunnerBundleID )
500+ if err != nil {
501+ return uuid.UUID {}, "" , nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
502+ }
503+
518504 houseArrestService , err := house_arrest .New (device , testRunnerBundleID )
519- defer houseArrestService .Close ()
520505 if err != nil {
521506 return uuid.UUID {}, "" , nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
522507 }
508+ defer houseArrestService .Close ()
509+
523510 log .Debugf ("creating test config" )
511+ testSessionID := uuid .New ()
524512 testConfigPath , testConfig , err := createTestConfigOnDevice (testSessionID , info , houseArrestService , xctestConfigFileName , testsToRun , testsToSkip , isXCTest , version )
525513 if err != nil {
526514 return uuid.UUID {}, "" , nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
@@ -529,6 +517,44 @@ func setupXcuiTest(device ios.DeviceEntry, bundleID string, testRunnerBundleID s
529517 return testSessionID , testConfigPath , testConfig , info , nil
530518}
531519
520+ func setupXcuiTest12 (device ios.DeviceEntry , bundleID string , testRunnerBundleID string , xctestConfigFileName string , testsToRun []string , testsToSkip []string , isXCTest bool , version * semver.Version ) (uuid.UUID , nskeyedarchiver.XCTestConfiguration , testInfo , error ) {
521+ testSessionID := uuid .New ()
522+ installationProxy , err := installationproxy .New (device )
523+ if err != nil {
524+ return uuid.UUID {}, nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
525+ }
526+ defer installationProxy .Close ()
527+
528+ apps , err := installationProxy .BrowseUserApps ()
529+ if err != nil {
530+ return uuid.UUID {}, nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
531+ }
532+
533+ testAppInfo , err := getappInfo (testRunnerBundleID , apps )
534+ if err != nil {
535+ return uuid.UUID {}, nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
536+ }
537+
538+ info := testInfo {
539+ testApp : testAppInfo ,
540+ }
541+
542+ if bundleID != "" {
543+ appInfo , err := getappInfo (bundleID , apps )
544+ if err != nil {
545+ return uuid.UUID {}, nskeyedarchiver.XCTestConfiguration {}, testInfo {}, err
546+ }
547+ log .Debugf ("app info found: %+v" , appInfo )
548+
549+ info .targetApp = appInfo
550+ }
551+
552+ log .Debugf ("creating test config" )
553+ testConfig := createTestConfig (info , testSessionID , xctestConfigFileName , testsToRun , testsToSkip , isXCTest , version )
554+
555+ return testSessionID , testConfig , info , nil
556+ }
557+
532558func createTestConfigOnDevice (testSessionID uuid.UUID , info testInfo , houseArrestService * house_arrest.Connection , xctestConfigFileName string , testsToRun []string , testsToSkip []string , isXCTest bool , version * semver.Version ) (string , nskeyedarchiver.XCTestConfiguration , error ) {
533559 relativeXcTestConfigPath := path .Join ("tmp" , testSessionID .String ()+ ".xctestconfiguration" )
534560 xctestConfigPath := path .Join (info .testApp .homePath , relativeXcTestConfigPath )
0 commit comments