-
Notifications
You must be signed in to change notification settings - Fork 8
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 missing configuration/features to Smithy build plugin #356
Comments
Issue #, if available: Fixes #298 Description of changes: This trait is ideal for filling a testing gap in our TestModels. Because our strategy for mapping Smithy shapes to Dafny types enforces constraints statically, it's not possible to express invalid input without lying to Dafny through axioms that aren't actually true, or in some cases (such as @required) not possible at all. smokeTests instances generate tests that specify inputs at the Smithy level using document types (i.e. more or less JSON valued arguments to the trait), which generate target language tests using the customer-facing interfaces such as builders to create input, and can therefore express invalid input as well. The key new component in the implementation is the ModeledShapeValue.shapeValue method, which creates a code block in Java expressing the given Shape value. Similar logic already appears in other smithy code generators, although mostly for HTTP Protocol Compliance Tests instead. I mainly imitated the structure of smithy-python's logic, but was also inspired by smithy-typescript and smithy-rs. Because this feature introduces a new category of generated code (Smithy-generated tests) this PR also adds an --output-java-test option with SmithyDafnyMakefile.mk support. We will likely need to add a similar parameter for the other languages. It may make more sense to migrate to smithy-build.json first though: #356. It also adds ./gradlew test as an additional step for make test_java, since running the Java @tests is distinct from executing the transpiled dafny test program. Finally, it also improves the CLI interface to print out validation events even if there are only warnings. Besides providing previously hidden but useful information in general, this provides a way to warn against using smokeTests outside of test models - since it doesn't/can't support @reference shapes it's not terribly useful as a testing method for local services themselves.
Note the scope of this issue is only for CLI options that are relevant in |
Here is some more detail on the scope of this task vs. future ones. One key difference between the CLI and the Smithy build plugin is how they use input and output. The CLI has options like I believe the best way to bridge this gap is with an additional shared Gradle plugin that can be executed after invoking the The plugin would have three different tasks (or at least modes of a single task):
It looks like this is the only missing "feature" to make this work. For the record here is the analysis I did of the current set of CLI options: CLI options that need new smithy-build.json equivalents
CLI options that already have smithy-build.json equivalents
CLI options not yet relevant (because they will apply to
|
…lugin-based SQS TestModel (#395) *Issue #, if available:* #356 (related) *Description of changes:* This PR allows the Smithy Build Plugin-based SQS TestModel to be built and structured similarly to the Makefile/CLI based models used elsewhere. This enables some Smithy features which are not supported by the CLI, such as [Projections](https://smithy.io/2.0/guides/smithy-build-json.html#projections). Instead of running `make polymorph_dafny` and `make polymorph_dotnet`, run `./gradlew polymorphDafny` and `./gradlew polymorphDotnet` to generate types for the respective languages. A Makefile is included, as it is needed to run `make transpile_net` and `make test_net`, which work as expected when the above commands are executed.
The number and complexity of CLI arguments are getting out of hand. We already have an alternate interface into the code generation logic as a Smithy build plugin, which supports configuration via a
smithy-build.json
. It also supports standard Smithy features such as projections because it hooks into the full Smithy model building pipeline.This task is to add the missing necessary configuration knobs to our
smithy-build.json
configuration handler so that we can migrate off the CLI.(More specific design for how these options should map to
smithy-build.json
configuration pending...)The text was updated successfully, but these errors were encountered: