Allows specifying which features to build, test and lint #151
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.
Rust has the ability to specify optional features (think
#ifdef
in C/C++), as well as default features. When running any of the tooling without additional options (cargo test
,cargo build
,cargo clippy
), only the default features are activated, which means that the code that is behind the other features goes untested, unlinted and unbuilt.In an ideal world, we would thus run unit tests for every possible subset of the set of possible features. This is possible with
cargo hack
, although it leads to long CI times and is thus undesireable.A good tradeoff is this:
--all-features
cargo hack
to just check all possible features to make sure they at least are compileableThis workflow catches the vast majority of issues related to working with feature-gated code. However, this workflow is currently not easily possible because we do not enable
--all-features
on ourcargo_test
andcargo_clippy
tasks.What this PR does is add some handles that allow us to enable
--all-features
(or specific features) on our test and clippytasks.
Specifically, this gives us some fine control over which features are enabled:
The idea is that at some point (after perhaps discussing it), we could change
autoconf()
to setting the features toCargoBuildFeatures(all = True)
for the test and clippy tasks by default, to make sure that we really do run all tests in CI, and not just the ones for the features that happen to be enabled by default.