Build: Fix test forks and memory calculations for low memory cases

This commit is contained in:
Vyacheslav Gerasimov
2022-05-27 21:05:48 +03:00
parent 2deb0cc237
commit 7360dff0da
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -183,7 +183,7 @@ fun Project.projectTest(
project.kotlinBuildProperties.junit5NumberOfThreadsForParallelExecution ?: Runtime.getRuntime().availableProcessors()
val memoryPerTestProcessMb = maxHeapSizeMb ?: if (jUnitMode == JUnitMode.JUnit5)
totalMaxMemoryForTestsMb.coerceAtMost(defaultMaxMemoryPerTestWorkerMb * junit5ParallelTestWorkers)
totalMaxMemoryForTestsMb.coerceIn(defaultMaxMemoryPerTestWorkerMb, defaultMaxMemoryPerTestWorkerMb * junit5ParallelTestWorkers)
else
defaultMaxMemoryPerTestWorkerMb
@@ -243,7 +243,7 @@ fun Project.projectTest(
val forks = (totalMaxMemoryForTestsMb / memoryPerTestProcessMb).coerceAtMost(16)
maxParallelForks =
project.providers.gradleProperty("kotlin.test.maxParallelForks").forUseAtConfigurationTime().orNull?.toInt()
?: forks.coerceAtMost(Runtime.getRuntime().availableProcessors())
?: forks.coerceIn(1, Runtime.getRuntime().availableProcessors())
}
}.apply { configure(body) }
}
@@ -201,7 +201,7 @@ if (isTeamcityBuild) {
val KGP_TEST_TASKS_GROUP = "Kotlin Gradle Plugin Verification"
val memoryPerGradleTestWorkerMb = 6000
val maxParallelTestForks =
(totalMaxMemoryForTestsMb / memoryPerGradleTestWorkerMb).coerceAtMost(Runtime.getRuntime().availableProcessors())
(totalMaxMemoryForTestsMb / memoryPerGradleTestWorkerMb).coerceIn(1, Runtime.getRuntime().availableProcessors())
val allParallelTestsTask = tasks.register<Test>("kgpAllParallelTests") {
group = KGP_TEST_TASKS_GROUP