Skip to content

Add a plugin test runner and a test for types-codegen simple types#855

Merged
adwsingh merged 6 commits intosmithy-lang:mainfrom
sugmanue:sugmanue/add-codegen-plugin-test-runner
Aug 25, 2025
Merged

Add a plugin test runner and a test for types-codegen simple types#855
adwsingh merged 6 commits intosmithy-lang:mainfrom
sugmanue:sugmanue/add-codegen-plugin-test-runner

Conversation

@sugmanue
Copy link
Contributor

@sugmanue sugmanue commented Aug 23, 2025

Issue #, if available:

Description of changes:

This change adds a utility class PluginTestRunner that can be used by all codegen plugins to validate the code being generated.

Also added a single test for the TypeCodegenPlugin.

The below issue was fixed in #856

This test shows a currently existing bug in the builders for nullable types, the setters are codegen to take primitive types which will make .toBuilder() to fail if a nullable type is null and will make it impossible to update a member from a non-null value to a null one. E.g., this will fail:

   PrimitivesNullable.builder()
        .longMember(10L)
        .build()
        .toBuilder()
        .longMember(null)
        .build();

I will fix that issue after merging this change.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines +42 to +43
// Uncomment this test to render the java files when we there are changes to the codegen logic.
@ParameterizedTest(name = "[{index}] => {0}") @MethodSource("testCases")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant to comment this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. Let me fix that.

@adwsingh adwsingh enabled auto-merge (squash) August 25, 2025 22:03
@adwsingh adwsingh merged commit 9c051ba into smithy-lang:main Aug 25, 2025
2 checks passed
@sugmanue sugmanue deleted the sugmanue/add-codegen-plugin-test-runner branch August 25, 2025 22:03
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