Skip to content

Commit

Permalink
[K/N][tests] Don't attempt to download simulator after first failure
Browse files Browse the repository at this point in the history
Sometimes, e.g. due to a bug in Xcode, downloading a simulator runtime
might fail. See e.g. 89589210 here:
https://developer.apple.com/documentation/xcode-release-notes/xcode-14-release-notes

In that case, it makes little sense to try downloading the same
simulator runtime later again.
Moreover, such attempts might lead to accumulating stale downloads in
/Library/Developer/CoreSimulator/Images/Inbox/, wasting disk space.

This commit caches the download result, so that if the first attempt
fails, then the later attempts will just rethrow the same exception.

^KTI-1683
  • Loading branch information
SvyatoslavScherbina authored and qodana-bot committed Apr 2, 2024
1 parent 8a15106 commit b487d67
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,13 @@ class XcodeSimulatorExecutor(
return checkNotNull(simulatorRuntimeOrNull()) { "Runtime is not available for the selected $deviceId. Check Xcode installation" }
}

private fun downloadRuntimeFor(osName: String) {
private val downloadRuntimeResultByOsName = mutableMapOf<String, Result<Unit>>()

private fun downloadRuntimeFor(osName: String) = downloadRuntimeResultByOsName.getOrPut(osName) {
runCatching { downloadRuntimeForImpl(osName) }
}.getOrThrow()

private fun downloadRuntimeForImpl(osName: String) {
val version = Xcode.findCurrent().version
check(version.major >= 14) {
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"
Expand Down

0 comments on commit b487d67

Please # to comment.