Skip to content
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

Add workaround for issue where no tests are run when using new Kotlin/Native memory model. #2812

Merged
merged 1 commit into from
Feb 7, 2022

Conversation

charleskorn
Copy link
Contributor

See https://kotlinlang.slack.com/archives/CT0G9SD7Z/p1636921822112900.

In the old memory model, global properties are eagerly initialised, whereas in the new memory model, they are lazily initialised (source). The impact of this is that a project using the new memory model will not run any tests.

Annotating properties with @EagerInitialization changes the behaviour to match the old memory model.

Caveats:

  • I couldn't find an easy way to test this within the existing test setup. If you have any suggestions, happy to add a test for this.

  • This is only a workaround: the docs for @EagerInitialization emphasise that we should not rely on this annotation in the long term.

@charleskorn
Copy link
Contributor Author

I should also say that I have very limited experience with compiler plugins - this works, but there may well be better ways to do this.

@sksamuel sksamuel merged commit ae96301 into kotest:master Feb 7, 2022
@sksamuel
Copy link
Member

sksamuel commented Feb 7, 2022

Seems reasonable to me. Assuming it still works on old memory model (I assume it ignores the annotation).

@sksamuel sksamuel added this to the 5.2 milestone Feb 7, 2022
@charleskorn
Copy link
Contributor Author

Assuming it still works on old memory model (I assume it ignores the annotation).

Yep, that's exactly what it does.

@sksamuel sksamuel mentioned this pull request Mar 12, 2022
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants