Skip to content

Allow arti cfg.rs test cases to more precisely control cargo features

Ian Jackson requested to merge Diziet/arti:precise into main

We want to have a cargo feature tor-memquota/memquota which will be enabled by default in tor-memquota. But we also want to continue to test, in crates/arti/src/cfg.rs, builds without that feature enabled.

If we run cargo test --workspace, we enable default features of all crates, not just the toplevel. We could run with --no-default-features or have a bespoke job, but that would mean precisely specifying the right set of features in the CI, for each crate, in .gitlab-ci.yml, entangling the CI even further with crate-specific knowledge.

Instead, use the minimal-features-test job for this. It's well-suited, since it compiles every crate separately, thereby avoiding cargo feature unificatiion. All we need to do is:

  1. Provide a way for crates to declare the minimal features they need for their own tests, making it possible to have arti tested in that test job, rather than ignored as it is right now.
  2. Have a way for the test case in cfg.rs to know that it's running without unexpected features enabled in its dependencies.

A run where I have deliberately sabotaged the test can be found here: https://gitlab.torproject.org/Diziet/arti/-/jobs/722256. That shows that the new testing strategy is effective. (That run also used the --start-from feature, and promoted the minimal-features-test job to the start of the pipeline.)

Part of #351 (closed)

Edited by Ian Jackson

Merge request reports

Loading