smithy-rs/codegen-client-test
david-perez fbde9d8700
Do not set `RUSTFLAGS` environment variable when invoking Cargo commands via Gradle tasks (#3678)
Otherwise, if you generate a crate and compile it using Gradle, like for
example using the invocation:

```
./gradlew -P modules='simple' -P cargoCommands='test' codegen-server-test:build
```

And then manually run a `cargo` command within the generated crate
directory, or open the project using `rust-analyzer`, Cargo will
re-compile the project from scratch, with
`CARGO_LOG=cargo::core::compiler::fingerprint=trace` reporting that
flags have changed since the last compilation.

Instead, it's best if we persist these flags to `.cargo/config.toml`, so
all `cargo` invocations, either through Gradle, manually, or through
`rust-analyzer`, use the same set. This way, if no files were changed,
subsequent compilations since code generation will truly be no-ops, with
Cargo reusing all artifacts.

Note this commit fixes a regression that was introduced when `--cfg
aws_sdk_unstable` was introduced in #2614, since I fixed this the first
time back in #1422.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
2024-06-21 14:26:22 +00:00
..
model Upgrade Smithy to 1.45 (#3470) 2024-03-08 13:16:02 -08:00
.gitignore Establish the `codegen-core` module (#1697) 2022-09-07 09:31:46 -07:00
README.md Break up `RustCodegenDecorator` (#2099) 2022-12-14 13:26:55 -08:00
build.gradle.kts Do not set `RUSTFLAGS` environment variable when invoking Cargo commands via Gradle tasks (#3678) 2024-06-21 14:26:22 +00:00

README.md

Codegen Integration Tests

This module defines integration tests of the code generation machinery. ./build.gradle.kts will generate a smithy-build.json file as part of the build. The rust-client-codegen Smithy build plugin then invokes our codegen machinery and generates Rust crates, one for each of the integration test services defined under model/.

Usage

These commands are all meant to be run from the repository root.

To run all protocol tests of all the integration test services:

./gradlew codegen-client-test:build

To run only a subset of the integration test services (refer to ./build.gradle.kts for a full list):

./gradlew codegen-client-test:build -P modules='simple,rest_json'

The Gradle task will run cargo check, cargo test, cargo docs and cargo clippy by default on all the generated Rust crates. You can also specify a subset of these commands. For instance, if you're working on documentation and want to check that the crates also compile, you can run:

./gradlew codegen-client-test:build -P cargoCommands='check,docs'

For fast development iteration cycles on protocol tests, we recommend you write a codegen unit test with a minimal service definition and only run that unit test. Alternatively, you can write a minimal integration test service definition in model/simple.smithy and run:

./gradlew codegen-client-test:build -P cargoCommands='test' -P modules='simple'