From 5b8a4ccd56c7f2af2b9afabed549a302094a17f2 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Mon, 27 Jun 2022 18:53:49 +0200 Subject: [PATCH] Use cache-redirector for downloading in parcelize tests There's a flaky failures when ~/.m2/repository/org/robolectric/android-all/5.0.2_r3-robolectric-r0/android-all-5.0.2_r3-robolectric-r0.jar is partially downloaded during tests execution. This led to Parcelize tests failure with: Caused by: java.util.zip.ZipException: invalid LOC header (bad signature) at java.util.zip.ZipFile.read(Native Method) at java.util.zip.ZipFile.access$1400(ZipFile.java:60) at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:734) at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:434) at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158) at java.io.FilterInputStream.read(FilterInputStream.java:133) at java.io.FilterInputStream.read(FilterInputStream.java:107) at org.robolectric.util.Util.copy(Util.java:21) at org.robolectric.util.Util.readBytes(Util.java:38) at org.robolectric.internal.bytecode.SandboxClassLoader.getByteCode(SandboxClassLoader.java:166) ... 36 more Option used was found at https://github.com/robolectric/robolectric/blob/7697d1217c5eb0dee454004efe60ba219f398255/plugins/maven-dependency-resolver/src/main/java/org/robolectric/MavenRoboSettings.java#L19 ^KTI-842 Fixed --- buildSrc/src/main/kotlin/tasks.kt | 1 + .../parcelize/test/services/ParcelizeMainClassProvider.kt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/tasks.kt b/buildSrc/src/main/kotlin/tasks.kt index 73857d7020e..3f4ffaddeaa 100644 --- a/buildSrc/src/main/kotlin/tasks.kt +++ b/buildSrc/src/main/kotlin/tasks.kt @@ -204,6 +204,7 @@ fun Project.projectTest( systemProperty("jps.kotlin.home", project.rootProject.extra["distKotlinHomeDir"]!!) systemProperty("kotlin.ni", if (project.rootProject.hasProperty("newInferenceTests")) "true" else "false") systemProperty("org.jetbrains.kotlin.skip.muted.tests", if (project.rootProject.hasProperty("skipMutedTests")) "true" else "false") + systemProperty("cacheRedirectorEnabled", project.rootProject.findProperty("cacheRedirectorEnabled")?.toString() ?: "false") project.kotlinBuildProperties.junit5NumberOfThreadsForParallelExecution?.let { n -> systemProperty("junit.jupiter.execution.parallel.config.strategy", "fixed") systemProperty("junit.jupiter.execution.parallel.config.fixed.parallelism", n) diff --git a/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/services/ParcelizeMainClassProvider.kt b/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/services/ParcelizeMainClassProvider.kt index 97d7bda0108..714f2fa9cde 100644 --- a/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/services/ParcelizeMainClassProvider.kt +++ b/plugins/parcelize/parcelize-compiler/tests/org/jetbrains/kotlin/parcelize/test/services/ParcelizeMainClassProvider.kt @@ -12,7 +12,9 @@ import org.junit.runner.JUnitCore class ParcelizeMainClassProvider(testServices: TestServices) : JvmBoxMainClassProvider(testServices) { override fun getMainClassNameAndAdditionalArguments(): List { - return listOf( + return listOfNotNull( + "-Drobolectric.dependency.repo.url=https://cache-redirector.jetbrains.com/maven-central" + .takeIf { "true" == System.getProperty("cacheRedirectorEnabled") }, JUnitCore::class.java.name, JUNIT_GENERATED_TEST_CLASS_FQNAME )