Repository navigation
test: add shared generator conformance suite for codegen backends (#420) - #430
Open
igel-devin-ai wants to merge 27 commits into
Open
igel-devin-ai wants to merge 27 commits into
igel-devin-ai wants to merge 27 commits into
Conversation
…ssue-412-field-name-examples' into test/generator-conformance-suite
…r-conformance-suite
…ator-conformance-suite
…ssue-418-keyword-property-names' into test/generator-conformance-suite
…covery Introduces GeneratorConformanceTest in codegen-testing: backend-agnostic contract tests that verify every ClassCodeGenerator emits compilable, semantically correct Java source for a common set of model fixtures (fields/methods/ctors, generics, collections, nested types, annotations, code templates, static imports, colliding type names). Backends bind via the TestBackendProvider SPI discovered through ServiceLoader, so each generator module opts in with a provider class and services file - no test code is duplicated per backend. Parameterized invocations are named after the provider so failures identify the failing generator. codegen-roaster registers RoasterTestBackendProvider and scans the suite from the codegen-testing jar via surefire dependenciesToScan. This is the acceptance harness needed before adding further generator implementations (issue java-helpers#366). Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…-420-generator-conformance-suite
…rator-conformance-suite
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #420.
Adds a backend-neutral conformance suite that every
ClassCodeGeneratorimplementation must pass: Roaster today, the built-in backend (#364) and JavaPoet later. No backend has to duplicate the tests.GeneratorConformanceTestand theTestBackendProviderSPI live incodegen-testing.ServiceLoaderfinds the providers, creating each one once, and each provider's name appears in the test names.RoasterTestBackendProviderin codegen-roaster uses the real default formatter profile. Surefire'sdependenciesToScanpicks the suite up from the codegen-testing jar.Optional, nested types, annotations including TYPE_USE, code-template placeholders, static imports, supertype and interfaces, Javadoc, and colliding simple type names (Fields of different types sharing a simple name (e.g. java.util.Date / java.sql.Date) generate uncompilable builder #417). Each fixture checks that javac compiles the output, including the Javadoc fixture, and that the declarations match exactly (text blocks, no fragment or OR asserts).*DtoBuilders. No DTO is changed afterbuild().Found by the stricter asserts: Roaster dropped type-use annotations on field and return types. This is fixed in #434 (issue #433).
Dependencies
This branch contains the commits of #425, #429 (and through it #426, #428, #436) and #434. The diff shrinks to the suite once they are merged.
Tradeoffs (deliberately kept)
src/main:GeneratorConformanceTeststays insrc/mainofcodegen-testing, so backends can find it viadependenciesToScan. Only junit-jupiter api/params are compile scope; the engine is test scope.TypeNameannotation setup: aTypeNameis a type value, not one of the Builders for codegen model DTOs (GenerationTargetClassDto & friends) #415 DTOs, and has no builder. The TYPE_USE fixture therefore annotates it withaddAnnotation(...)before passing it into a builder.Verified:
mvn clean verifypasses, and GeneratorConformanceTest runs 10 tests in codegen-roaster.