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

Allow larger common test resources #355

Merged
merged 3 commits into from
Jan 10, 2025
Merged

Conversation

krzema12
Copy link
Owner

@krzema12 krzema12 commented Jan 10, 2025

Part of #354

Before this change, the build logic took all test resources, and converted them into Kotlin code that was building a map using a single expression with using nested mapOf function to represent the directory structure. However, when trying to move existing JVM-specific resources (there's a lot of them), one could see a failing build with:

exception: java.lang.RuntimeException: Error generating class file CommonTestResources.class (compiled from [/Users/piotr/repos/snakeyaml-engine-kmp/build/generated-code-for-resources/src/commonTest/kotlin/CommonTestResources.kt]): Method too large: CommonTestResources.<clinit> ()V
e

This change puts every call to mapOf(...) or ByteString.of(...) into a separate method, so that now the limitation is either the maximum number of files/directories in a given directory, or size of a single file. It should unblock migrating tests to the common source set that rely on the large number of files (see a work-in-progress PR: #356).

It was still faster to not use KotlinPoet, but the generated code became even more ugly. It's likely that I'm going to use KotlinPoet, especially that I'm planning to extract this functionality into a library.

@krzema12 krzema12 changed the title Allow more common test resources Allow larger common test resources Jan 10, 2025
@krzema12 krzema12 requested a review from OptimumCode January 10, 2025 13:39
@krzema12 krzema12 marked this pull request as ready for review January 10, 2025 13:39
@krzema12 krzema12 enabled auto-merge (squash) January 10, 2025 15:58
@krzema12 krzema12 merged commit af72b63 into main Jan 10, 2025
12 checks passed
@krzema12 krzema12 deleted the allow-more-common-test-resources branch January 10, 2025 16:24
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