So, I've just switched to the <final release of Ko...
# scripting
s
So, I've just switched to the final release of Kotlin 2.0.0 in my project, but now I'm getting strange failure in the test for my custom scripts: It seems that some test cases use the input for scripts from previous test cases. Has something changed e.g. WRT script caching that migrators should be aware of?
Ping @Piotr Krzemiński also from here 😉
thank you color 1
i
I do not expect any scripting-related changes that affect cases like yours. I tried to debug the test briefly, and without understanding much of the internals, I see that the
ortResult
object that is passed to the script constructor here is exactly the same object that is created in the beginning of the test. Why do you think it is a wrong one? And also there are only a few failing tests. so some fundamental parameter passing bugs would probably break most of them.
s
Thanks for looking into this @ilya.chernikov! I expect the
incompatibleOrtResult
to get passed, see here, but instead that tests seems to use the
ortResult
data from here (same file, earlier test case). Could there be some weird conflict between my global
ortResult
variable (from
org.ossreviewtoolkit.evaluator.ortResult
) and my DSL builder for the data class that is also called
ortResult
and defined here?
i
I can imagine that some general K2 changes, e.g. in resolution, can have such effect. But formally, what I see in the debugger is the exactly what you describe as a desired state, at least speaking about objects, not the contents. If I'm not mistaken, of course. Lets check my screenshots - the
incompatibleOrtResult
is marked. First frame at the test body, and second - before constructing the script class
s
Screenshot-wise that looks indeed good. But with K2 the test fails with debug lines like
Copy code
12:13:49.202 [pool-1-thread-1] INFO  org.ossreviewtoolkit.evaluator.Rule - Evaluating rule 'OSADL_MATRIX_COMPATIBILITY' for dependency 'Maven:org.ossreviewtoolkit:package-excluded:1.0' (project=Maven:org.ossreviewtoolkit:project-excluded:1.0, scope=compile, level=0).
12:13:49.203 [pool-1-thread-1] INFO  org.ossreviewtoolkit.evaluator.Rule - 	!(isExcluded()) == false
12:13:49.203 [pool-1-thread-1] INFO  org.ossreviewtoolkit.evaluator.Rule - 	Rule skipped.
where
Maven:org.ossreviewtoolkit:project-excluded:1.0
is a project that's not even present in
incompatibleOrtResult
, but only in the
ortResult
global test data. Reverting to Kotlin 1.9.24 makes the test pass again.
And please don't get me wrong, it could totally be that I'm doing something shady (without knowing) that just happened to work in Kotlin 1.9.24, but actually shouldn't, and was fixed in K2, so I'm now facing it. I'm just completely clueless what could cause this kind of behavior.
But you can reproduce the test failing with K2, right @ilya.chernikov?
i
So, I figured out. The problem is changed resolution scheme for scripts, where imported declarations are preferred. You have the
org.ossreviewtoolkit.evaluator.ortResult
imported by default, and the access is resolved to it instead of the constructor parameter. Actually the usage of the constructor parameters is obsolete, we should probably issue a warning there. The recommended approach is to use
providedProperties
. The patch below fixes it properly (and it should work for K1 as well). But thank you for the issue - we should definitely address it in some way.
Untitled
s
Thanks a lot for the speedy investigation @ilya.chernikov, that's highly appreciated!
Unfortunately, I'm running into the next problem:
providedProperties
from script compilation and script evaluation do not add up, but replace each other. Is this expected?
Ah, no scratch that. I was calling
providedProperties
for evaluation twice.
👍 1
One more feedback yet: After migrating
constructorArgs
to
providedProperties
, IntelliJ does not seem to be able to resolve them in scripts anymore... e.g. my
ortResult
is now always marked in red, although the scripts runs fine:
i
Ok, I see. Yes, the IDE support is far from ideal, but we're working on it. Please submit an issue about it too.
s
Oh, I was expecting there surely already is an issue about this already, as it's a quite obvious limitation. I'll check first to be on the safe side. Interestingly, it seems to work in Fleet, though.
i
No, it is a different different problem.
s
i
Thanks! We'll try to take care of it.
👍🏻 1