Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to enable features in the configuration #1402

Open
usagi-flow opened this issue Mar 27, 2024 · 3 comments
Open

Ability to enable features in the configuration #1402

usagi-flow opened this issue Mar 27, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@usagi-flow
Copy link

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!

@sunshowers
Copy link
Member

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.

@sunshowers sunshowers added the enhancement New feature or request label Apr 9, 2024
@greg-kinasa
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants