From 8a1d5cdf404607ed3262fd6a8c3fc229ace7dcfb Mon Sep 17 00:00:00 2001 From: herval Date: Mon, 9 Dec 2024 16:14:48 -0500 Subject: [PATCH] allow remote xctest connections w/ a flag --- maestro-ios-driver/src/main/kotlin/util/XCRunnerCLIUtils.kt | 4 ++-- .../main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt | 2 ++ .../maestro-driver-iosUITests/Routes/XCTestHTTPServer.swift | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/maestro-ios-driver/src/main/kotlin/util/XCRunnerCLIUtils.kt b/maestro-ios-driver/src/main/kotlin/util/XCRunnerCLIUtils.kt index b0c1577da8..fd2a8676bd 100644 --- a/maestro-ios-driver/src/main/kotlin/util/XCRunnerCLIUtils.kt +++ b/maestro-ios-driver/src/main/kotlin/util/XCRunnerCLIUtils.kt @@ -121,7 +121,7 @@ object XCRunnerCLIUtils { return runningApps(deviceId)[bundleId] } - fun runXcTestWithoutBuild(deviceId: String, xcTestRunFilePath: String, port: Int, enableXCTestOutputFileLogging: Boolean = false): Process { + fun runXcTestWithoutBuild(deviceId: String, xcTestRunFilePath: String, port: Int, enableXCTestOutputFileLogging: Boolean = false, acceptRemoteConnections: Boolean = false): Process { val date = dateFormatter.format(LocalDateTime.now()) val outputFile = if (enableXCTestOutputFileLogging) { File(logDirectory, "xctest_runner_$date.log") @@ -142,7 +142,7 @@ object XCRunnerCLIUtils { ), waitForCompletion = false, outputFile = outputFile, - params = mapOf("TEST_RUNNER_PORT" to port.toString()) + params = mapOf("TEST_RUNNER_PORT" to port.toString(), "ACCEPT_REMOTE_CONNECTIONS" to acceptRemoteConnections.toString()) ) } } diff --git a/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt b/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt index 8af21430dc..a68b73a820 100644 --- a/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt +++ b/maestro-ios-driver/src/main/kotlin/xcuitest/installer/LocalXCTestInstaller.kt @@ -30,6 +30,7 @@ class LocalXCTestInstaller( connectTimeout = 1.seconds, readTimeout = 100.seconds, ), + private val acceptRemoteConnections: Boolean = false, ) : XCTestInstaller { private val logger = LoggerFactory.getLogger(LocalXCTestInstaller::class.java) @@ -202,6 +203,7 @@ class LocalXCTestInstaller( xcTestRunFilePath = xctestRunFile.absolutePath, port = defaultPort, enableXCTestOutputFileLogging = enableXCTestOutputFileLogging, + acceptRemoteConnections = acceptRemoteConnections, ) logger.info("[Done] Running XcUITest with `xcodebuild test-without-building`") } diff --git a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/XCTestHTTPServer.swift b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/XCTestHTTPServer.swift index 546b69a129..7b21c23158 100644 --- a/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/XCTestHTTPServer.swift +++ b/maestro-ios-xctest-runner/maestro-driver-iosUITests/Routes/XCTestHTTPServer.swift @@ -28,7 +28,7 @@ struct XCTestHTTPServer { let port = ProcessInfo.processInfo.environment["PORT"]?.toUInt16() let acceptRemoteConnections = ProcessInfo.processInfo.environment["ACCEPT_REMOTE_CONNECTIONS"] == "true" - let address: HTTPServer.Address = acceptRemoteConnections ? .any(port: port) : .loopback(port: port) + let address = acceptRemoteConnections ? .inet(port: port) : .loopback(port: port) for route in Route.allCases { let handler = await RouteHandlerFactory.createRouteHandler(route: route)