You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the hood, to do this, the uniffi_testing builds the cargo crate for the test target and then extracts the generated cdylib to be used to build bindings.
This implementation does not allow users to provide additional configuration arguments such as features, architectures, or optimization levels when building the cdylib. Which is particularaly important when working with bindings defined with uniffi procedural macros, which can be conditionally compiled with #[cfg_attr(feature = "optional", uniffi::export)].
As a result, it becomes impossible to test bindings that are gated by feature flags and are conditionally compiled, or when bindings generation is an optional feature of the crate (for example, under a --features "bindings" flag). This can lead to incomplete testing, missing test coverage for important functionality.
Steps to Reproduce
1. Attempt to run binding tests for a crate where bindings are an optional feature.
2. Observe that the generated cdylib does not include the optional feature, and the tests fail as a result.
A potential solution would be to allow users to specify extra cargo arguments via an optional environment variable. For example, adding support for an UNIFFI_CARGO_BUILD_EXTRA_ARGS variable:
This would allow users to pass arguments like --features "bindings" or specify different architectures or optimization levels for cdylib generation when running binding tests.
Background
The
uniffi_testing
allows users to test their bindings using the generic macro:Under the hood, to do this, the
uniffi_testing
builds the cargo crate for the test target and then extracts the generatedcdylib
to be used to build bindings.Currently, it is built in the following way:
Problem
This implementation does not allow users to provide additional configuration arguments such as features, architectures, or optimization levels when building the
cdylib
. Which is particularaly important when working with bindings defined with uniffi procedural macros, which can be conditionally compiled with#[cfg_attr(feature = "optional", uniffi::export)]
.As a result, it becomes impossible to test bindings that are gated by feature flags and are conditionally compiled, or when bindings generation is an optional feature of the crate (for example, under a --features "bindings" flag). This can lead to incomplete testing, missing test coverage for important functionality.
Steps to Reproduce
Sample Project
optional-bindings.
Proposed Solution
A potential solution would be to allow users to specify extra cargo arguments via an optional environment variable. For example, adding support for an
UNIFFI_CARGO_BUILD_EXTRA_ARGS
variable:This would allow users to pass arguments like --features "bindings" or specify different architectures or optimization levels for cdylib generation when running binding tests.
Sample Solution
Allow to configure how create is built for testing
The text was updated successfully, but these errors were encountered: