nextest-rs / nextest

A next-generation test runner for Rust.
https://nexte.st
Apache License 2.0
2.11k stars 92 forks source link

Ability to enable features in the configuration #1402

Open usagi-flow opened 5 months ago

usagi-flow commented 5 months ago

Despite looking through the documentation and issues, I couldn't find much besides https://github.com/nextest-rs/nextest/issues/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!

sunshowers commented 5 months ago

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:

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.

greg-kinasa commented 4 months ago

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.

usagi-flow commented 3 weeks ago

I came across https://github.com/taiki-e/cargo-config2: It might make sense using that to load the configuration...