Skip to content

Commit be1804c

Browse files
SvyatoslavScherbinaSpace Team
authored and
Space Team
committed
[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 b666160 commit be1804c

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ class XcodeSimulatorExecutor(
135135
return checkNotNull(simulatorRuntimeOrNull()) { "Runtime is not available for the selected $deviceId. Check Xcode installation" }
136136
}
137137

138-
private fun downloadRuntimeFor(osName: String) {
138+
private val downloadRuntimeResultByOsName = mutableMapOf<String, Result<Unit>>()
139+
140+
private fun downloadRuntimeFor(osName: String) = downloadRuntimeResultByOsName.getOrPut(osName) {
141+
runCatching { downloadRuntimeForImpl(osName) }
142+
}.getOrThrow()
143+
144+
private fun downloadRuntimeForImpl(osName: String) {
139145
val version = Xcode.findCurrent().version
140146
check(version.major >= 14) {
141147
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"

0 commit comments

Comments
 (0)