-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Update robolectric to version 4.16 in parcelize-compiler #5649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaschdoc
wants to merge
1
commit into
master
Choose a base branch
from
prr/jaschdoc/bump-robolectric-in-parcelize
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/additionalAnnotationTrigger.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| // TARGET_BACKEND: JVM_IR | ||
| // WITH_STDLIB | ||
|
|
||
| @file:JvmName("TestKt") | ||
|
|
||
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/changingBaseClassProperty.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| // WITH_STDLIB | ||
| // IGNORE K1 | ||
|
|
||
| @file:JvmName("TestKt") | ||
| package test | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| // WITH_STDLIB | ||
| // FULL_JDK | ||
|
|
||
| @file:JvmName("TestKt") | ||
| package test | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| // WITH_STDLIB | ||
| // FULL_JDK | ||
|
|
||
| @file:JvmName("TestKt") | ||
| package test | ||
|
|
||
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/mppAdditionalAnnotations_k1.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| // TARGET_BACKEND: JVM_IR | ||
| // IGNORE_BACKEND_K2: ANY | ||
| // LANGUAGE: +MultiPlatformProjects | ||
| // WITH_STDLIB | ||
|
|
||
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/mppAdditionalAnnotations_k2.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| // TARGET_BACKEND: JVM_IR | ||
| // IGNORE_BACKEND_K1: ANY | ||
| // LANGUAGE: +MultiPlatformProjects | ||
| // WITH_STDLIB | ||
|
|
||
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/mppWithExpectParcelable_k1.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| // TARGET_BACKEND: JVM_IR | ||
| // IGNORE_BACKEND_K2: ANY | ||
| // LANGUAGE: +MultiPlatformProjects | ||
| // WITH_STDLIB | ||
|
|
||
1 change: 0 additions & 1 deletion
1
plugins/parcelize/parcelize-compiler/testData/box/mppWithExpectParcelable_k2.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| // TARGET_BACKEND: JVM_IR | ||
| // IGNORE_BACKEND_K1: ANY | ||
| // LANGUAGE: +MultiPlatformProjects | ||
| // WITH_STDLIB | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,11 @@ | |
|
|
||
| package org.jetbrains.kotlin.parcelize.test.services | ||
|
|
||
| import org.hamcrest.BaseDescription | ||
| import org.jetbrains.kotlin.parcelize.test.services.ParcelizeDirectives.ENABLE_PARCELIZE | ||
| import org.jetbrains.kotlin.test.model.TestModule | ||
| import org.jetbrains.kotlin.test.services.RuntimeClasspathProvider | ||
| import org.jetbrains.kotlin.test.services.TestServices | ||
| import org.jetbrains.kotlin.test.services.jvm.compiledClassesManager | ||
| import org.jetbrains.kotlin.test.services.temporaryDirectoryManager | ||
| import org.jetbrains.kotlin.utils.PathUtil | ||
| import org.jetbrains.org.objectweb.asm.ClassWriter | ||
|
|
@@ -19,13 +19,19 @@ import org.jetbrains.org.objectweb.asm.Type | |
| import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter | ||
| import org.junit.runner.JUnitCore | ||
| import java.io.File | ||
| import kotlin.reflect.KClass | ||
|
|
||
| class ParcelizeRuntimeClasspathProvider(testServices: TestServices) : RuntimeClasspathProvider(testServices) { | ||
| companion object { | ||
| val layoutlibJar: File by lazy { getLayoutLibFile("layoutLib.path") } | ||
| val layoutlibApiJar: File by lazy { getLayoutLibFile("layoutLibApi.path") } | ||
|
|
||
| private const val ANDROID_TOOLS_PREFIX = "studio.android.sdktools." | ||
| /** | ||
| * The android api version used by robolectric's `android-all`. | ||
| * | ||
| * See comment in gradle build file. | ||
| */ | ||
| private const val ANDROID_API_VERSION = 36 | ||
|
|
||
| private fun getLayoutLibFile(property: String): File { | ||
| val layoutLibFile = File(System.getProperty(property)) | ||
|
|
@@ -51,7 +57,7 @@ class ParcelizeRuntimeClasspathProvider(testServices: TestServices) : RuntimeCla | |
| } | ||
|
|
||
| with(visitAnnotation("Lorg/robolectric/annotation/Config;", true)) { | ||
| visit("sdk", intArrayOf(21)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, better to put a constant instead 👍🏼 |
||
| visit("sdk", intArrayOf(ANDROID_API_VERSION)) | ||
| visit("manifest", "--none") | ||
| visitEnd() | ||
| } | ||
|
|
@@ -110,13 +116,6 @@ class ParcelizeRuntimeClasspathProvider(testServices: TestServices) : RuntimeCla | |
| .map { File(it) } | ||
| .sortedBy { it.nameWithoutExtension } | ||
|
|
||
| val junitCoreResourceName = JUnitCore::class.java.name.replace('.', '/') + ".class" | ||
| val junitJar = File( | ||
| JUnitCore::class.java.classLoader.getResource(junitCoreResourceName)!!.file | ||
| .substringAfter("file:") | ||
| .substringBeforeLast('!') | ||
| ) | ||
|
|
||
| val parcelizeRuntimeJars = System.getProperty("parcelizeRuntime.classpath")?.split(File.pathSeparator)?.map(::File) | ||
| ?: error("Unable to get a valid classpath from 'parcelizeRuntime.classpath' property") | ||
|
|
||
|
|
@@ -126,14 +125,30 @@ class ParcelizeRuntimeClasspathProvider(testServices: TestServices) : RuntimeCla | |
| .resolve(JUNIT_GENERATED_TEST_CLASS_NAME) | ||
| .apply { writeBytes(JUNIT_GENERATED_TEST_CLASS_BYTES) } | ||
|
|
||
| val hamcrestJar = getJarFor(BaseDescription::class) | ||
| val junitJar = getJarFor(JUnitCore::class) | ||
|
|
||
| return buildList { | ||
| add(kotlinRuntimeJar) | ||
| add(layoutlibJar) | ||
| add(layoutlibApiJar) | ||
| addAll(robolectricJars) | ||
| add(junitJar) | ||
| add(hamcrestJar) | ||
| addAll(parcelizeRuntimeJars) | ||
| add(tempDir) | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns jar file where `clazz` is located by using `clazz`'s classloader. | ||
| */ | ||
| private fun getJarFor(clazz: KClass<out Any>): File { | ||
| val resourceName = clazz.java.name.replace('.', '/') + ".class" | ||
| return File( | ||
| clazz.java.classLoader.getResource(resourceName)!!.file | ||
| .substringAfter("file:") | ||
| .substringBeforeLast('!') | ||
| ) | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is my understanding correct that now we need
FULL_JDKfor all tests since robolectric requires JDK 21? Having these redundant directives caused the issue? Well, actually my question is the other way around: how do we know these are only tests that have redundant directives?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
FULL_JDKdirective is directly not redundant, but results in an error now. However, you do raise a good point that maybe there are other redundant directives in the Parcelize tests. I will investigate a bit further and see if I can remove any directives.A bit more context:
Both the
TestJdkKindandJvmEnvironmentConfigurationDirectives(I will abbreviate this asJvmEnvConfigDir) classes define aFULL_JDKdirective. It seems thatJvmEnvConfigDir.FULL_JDKis not used for much other than:TestJdkKind.FULL_JDKor throw an error if both directives are set inJvmEnvironmentConfigurator.One conclusion from these observations is that
JvmEnvConfigDir.FULL_JDKis almost redundant.Additionally, according to the documentation,
TestJdkKind.FULL_JDKis supposed to use the current JVM to run tests with, but inJvmBoxRunner, it is (mis-) used for looking up a JDK 8 in order to spawn a new JDK 8 process in which to run the tests.I hope that provides a bit more insight. From this perspective, it seems like removing
JvmEnvConfigDir.FULL_JDKis the best thing to do, but I can't at this point tell what other tests might break from doing so.