Skip to content

Commit 60eb01a

Browse files
SvyatoslavScherbinaBadya
authored andcommitted
[K/N][tests] Don't attempt to download simulator after first failure
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 (cherry picked from commit b487d67)
1 parent 0d7708d commit 60eb01a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

native/executors/src/main/kotlin/org/jetbrains/kotlin/native/executors/XcodeSimulatorExecutor.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,13 @@ class XcodeSimulatorExecutor(
141141
return checkNotNull(simulatorRuntimeOrNull()) { "Runtime is not available for the selected $deviceId. Check Xcode installation" }
142142
}
143143

144-
private fun downloadRuntimeFor(osName: String) {
144+
private val downloadRuntimeResultByOsName = mutableMapOf<String, Result<Unit>>()
145+
146+
private fun downloadRuntimeFor(osName: String) = downloadRuntimeResultByOsName.getOrPut(osName) {
147+
runCatching { downloadRuntimeForImpl(osName) }
148+
}.getOrThrow()
149+
150+
private fun downloadRuntimeForImpl(osName: String) {
145151
val version = Xcode.findCurrent().version
146152
check(version.major >= 14) {
147153
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"

0 commit comments

Comments
 (0)