-
Notifications
You must be signed in to change notification settings - Fork 12
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
Migrate compiler tests to "normal" unit tests #180
Comments
I take it you mean, create test That would definitely be easier to read, understand, and write. We'd lose two pretty nice things though:
Testing failure across backends sounds important, not sure I understand what you're envisioning here though?
Are you saying that I'm not varying the IR I've written across different targets, or that the Kotlin compiler doesn't ever convert the same IR to different bytecode based on JVM target? If the latter, do you have a link to where that's decided/described? That kinda bums me out, I assumed the Kotlin compiler would produce JVM target-specific optimizations somewhere along the line. |
You can still do this with a normal build but it's definitely more complicated. I tend to put all of the tests in this regular form, but leave one using the old/current mechanism. There will still be a bunch in the current mechanism for testing failures since it's the easiest way.
This is still easy. They become targets! So for the K2 example you'd do: jvm()
jvm("jvmK2") {
compilations.all {
compilerOptions.freeCompilerArgs += "-use-k2"
}
} Can do the same with any variation we want to support provided it can be achieved with compiler options or the DSL.
Nested Gradle builds which are puppeteered by Gradle TestKit. This is still somewhat testing Kotlin, though. I suspect we can rely on the JVM-based embedded compiler tests for scenarios that fail to compile and reasonably assume it will also work for the other backends.
At this time, yes. Mostly because you don't use anything interesting because the behavior of the generated code is so basic. The only candidate is probably the string concatenation for
I only know from having worked on some of the compiler intrinsics, but they're all available from all versions of the JVM supported now. For example, the Kotlin code That being said, this is another thing that still can technically be supported but maybe we reduce the versions tested since it's extremely unlikely anyone is using anything but the generally-agreed-upon LTS releases that JDK vendors put out, or the newest version of the OpenJDK. |
Sounds good 👍
Oh perfect, I didn't know you could duplicate the same target like this.
Ah you're right. All my failures are in IR compilation, which I believe would happen before anything platform-specific happens anyway. Eventually they'll mostly move to FIR which is even earlier.
I think what's not clicking for me is: why doesn't Anyway, I'm good with this plan!
Let's just focus on the migration and the latest Java target for now. Easy to play with re-adding a few more targets and seeing how that affects CI time later. Does Hopefully migrating the existing tests is fairly easy: All the private |
Punting this to #204 or even just a new feature request. I honestly am not 100% sure how it works so will have to find out. |
This is required for #142 as we cannot rely on the embedded Kotlin compiler to the same degree as when targeting the JVM backend, but it also becomes hard or impossible to execute the compiled target's code.
However, Kotlin has a mechanism which is built-in to do this for us: regular tests!
Regular tests written in
commonTest
will run on all supported targets of the host OS. Since Poko doesn't vary its IR based on backend, we really only need one JVM target, one JS target, and one native target to run each test. This will always be doable on every host OS since linux works on linux, macos on macos, and mingw on windows. JS and JVM work everywhere.This obviously only works for tests that have successful processing of the annotation. Failing tests can remain executed by the embedded Kotlin compiler, or migrate to a functional test if we want to test it across backends.
I also think this should come with removal of running these tests across multiple JDKs. Since the IR is not varied across different JVM targets, there's little reason to suspect the runtime behavior would be affected by different JVM versions as the reliance of platform APIs is near zero. Technically it is exactly zero as the APIs are all Kotlin APIs which should be guaranteeing behavioral compatibility across JVM versions.
Now maybe in the future when targeting 17 or higher we start using
invokedynamic
bytecodes on the JVM leveraging Java'sObjectsMethods
class which is what records use, but until that day varying the JDK is mostly redundant.The text was updated successfully, but these errors were encountered: