Skip to content

Rust doesn't cleanly support building separate --local-service-test test libraries #787

@robin-aws

Description

@robin-aws

Since Dafny itself doesn't support building code into separate crates, smithy-dafny works around this by translating and generating all code from all library dependencies at once. This is an issue for --local-service-test: all of the smithy-dafny TestModels always pass this when building each model, but some downstream projects like https://github.com/aws/aws-encryption-sdk only pass this option on separate projects like "TestVectors".

(TODO: more details, but that might go better under designs/rust instead)

To workaround these limitations, there are two separate hacks necessary (using https://github.com/aws/aws-encryption-sdk as a working example):

  1. Because the separate testing project reuses the source project Smithy model, there's no opportunity to provide extra @localService#dependencies, which is how the Rust code generation fills in the right Dafny include statements. Therefore they have to be patched onto the generated code: https://github.com/aws/aws-encryption-sdk/blob/mainline/TestVectors/dafny/TestVectors/Model/AwsCryptographyEncryptionSdkTypesWrapped.dfy#L5-L8
  2. Because all transitive dependencies are built at once, --local-service-test gets applied to all dependent Smithy models, which doesn't work in general because the wrapped clients depend on externs that won't be present on the root project. To work around this, the ESDK uses sed to comment out the wrapped clients on the dependent clients: https://github.com/aws/aws-encryption-sdk/blob/mainline/TestVectors/Makefile#L156-L157

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions