nextest-rs/nextest

Ability to enable features in the configuration

usagi-flow opened this issue · 2 comments

Despite looking through the documentation and issues, I couldn't find much besides #50 (which requests a bigger feature).

Is there a way - and if not, would it be possible - to define Cargo features which should be activated when building?

Basically, I'd like to specify features in the configuration which I would otherwise specify on the command line (cargo nextext run --features somefeature).

The way I'd imagine writing this in the configuration would be as follows:

[profile.default]
features = ["somefeature"]

PS: Thank you for this absolutely amazing tool, it's so much nicer than cargo test!

Hi @usagi-flow --

Thanks for the report. At the moment, this isn't supported -- nextest tries to customize the build process as little as possible. Though you make a compelling case, and I can definitely see how this may help.

I think we can borrow the weak feature syntax from Cargo. So:

[profile.default]
build.extra = [
    "p1/f1",
    "p2?/f2",
    "p3",
    "bin:b1",
]

What this says is:

  • Always include package p1 with feature f1.
  • If package p2 is being built, also enable feature f2.
  • Always include package p3.
  • Always include binary b1.

This can also be used in an additive fashion with overrides -- letting you say that: if e.g. rdeps(db-tests) is being built, also build a db-support binary.

Related (and possibly part of this enhancement) it would be great if there was a way to configure features for each crate within a workspace allowing something like run all tests with root/crate-a --features foo and root/crate-b --features bar. The features are not all additive unfortunately so running --all-features isn't an option. I can run them separately but that complicates CI and coverage output.