Skip to content

Commit

Permalink
[K/N][tests] Improve logging for issues with finding Xcode simulators
Browse files Browse the repository at this point in the history
This commit adds more logging to help investigate problems with
finding and downloading Xcode simulators in K/N tests.

* In case K/N test infra can’t find the matching Xcode simulator
  runtime after downloading it, show output of
    xcrun simctl list runtimes --json
  and
    xcrun simctl list devices --json

* When running `xcrun xcodebuild -downloadPlatform` or
  `-downloadAllPlatforms`, always log stdout and stderr.

^KT-68591

(cherry picked from commit 3220e08)
  • Loading branch information
SvyatoslavScherbina authored and qodana-bot committed Jun 14, 2024
1 parent e4ec8ac commit dcf5299
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,20 @@ class XcodeSimulatorExecutor(
logger.info("Runtime for the $deviceId is not available. Downloading runtimes for $target with Xcode")
downloadRuntimeFor(simulatorOsName(target.family))

return checkNotNull(simulatorRuntimeOrNull()) { "Runtime is not available for the selected $deviceId. Check Xcode installation" }
return checkNotNull(simulatorRuntimeOrNull()) {
"""
|Runtime is not available for the selected $deviceId. Check Xcode installation.
|osMinVersion = ${configurables.osVersionMin}
|$ xcrun simctl list runtimes --json
|_____
|${simctl("list", "runtimes", "--json")}
|-----
|$ xcrun simctl list devices --json
|_____
|${simctl("list", "devices", "--json")}
|-----
""".trimMargin()
}
}

private val downloadRuntimeResultByOsName = mutableMapOf<String, Result<Unit>>()
Expand All @@ -146,13 +159,15 @@ class XcodeSimulatorExecutor(
check(version.major >= 14) {
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"
}
if (version >= XcodeVersion(14, 1)) {
val runProcessResult = if (version >= XcodeVersion(14, 1)) {
// Option -downloadPlatform NAME available only since 14.1
hostExecutor.runProcess("/usr/bin/xcrun", "xcodebuild", "-downloadPlatform", osName)
} else {
// Have to download all platforms :(
hostExecutor.runProcess("/usr/bin/xcrun", "xcodebuild", "-downloadAllPlatforms")
}
logger.info("STDOUT:\n${runProcessResult.stdout}\n-----")
logger.info("STDERR:\n${runProcessResult.stderr}\n-----")
}

override fun execute(request: ExecuteRequest): ExecuteResponse {
Expand Down

0 comments on commit dcf5299

Please sign in to comment.