Build: Apply ConcurrencyLimitService to all tests tasks in the project

Some project tasks are not created with projectTest helper, but all
tasks should be limited since we can't use `--no-parallel` on CI
This commit is contained in:
Vyacheslav Gerasimov
2024-03-05 17:04:47 +01:00
parent b47a33cf9d
commit 879aa33a9c
2 changed files with 8 additions and 5 deletions
@@ -274,8 +274,16 @@ fun Project.configureTests() {
}
}
val concurrencyLimitService = project.gradle.sharedServices.registerIfAbsent(
"concurrencyLimitService",
ConcurrencyLimitService::class
) {
maxParallelUsages = 1
}
tasks.withType<Test>().configureEach {
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KTI-112") { true }
usesService(concurrencyLimitService)
}
// Aggregate task for build related checks
@@ -138,10 +138,6 @@ fun Project.projectTest(
defineJDKEnvVariables: List<JdkMajorVersion> = emptyList(),
body: Test.() -> Unit = {},
): TaskProvider<Test> {
val concurrencyLimitService =
project.gradle.sharedServices.registerIfAbsent("concurrencyLimitService", ConcurrencyLimitService::class) {
maxParallelUsages = 1
}
val shouldInstrument = project.providers.gradleProperty("kotlin.test.instrumentation.disable")
.orNull?.toBoolean() != true
if (shouldInstrument) {
@@ -225,7 +221,6 @@ fun Project.projectTest(
defaultMaxMemoryPerTestWorkerMb
maxHeapSize = "${maxHeapSizeMb ?: (memoryPerTestProcessMb - maxMetaspaceSizeMb - reservedCodeCacheSizeMb)}m"
usesService(concurrencyLimitService)
if (minHeapSizeMb != null) {
minHeapSize = "${minHeapSizeMb}m"