9

I'm using Cargo Features (https://doc.rust-lang.org/cargo/reference/features.html) to specify conditional compilation options. Is there a way to enable a set of these features for a given Cargo profile (https://doc.rust-lang.org/cargo/reference/profiles.html)?

For example, something like this (which does not seem to work):

[features]
foo = []

[profile.test]
features = ["foo"]

So that I don't have to write cargo test --features "foo" but will instead just write cargo test.

ynimous
  • 4,642
  • 6
  • 27
  • 43
  • 1
    I had the same issue once and I ended up writing a shell script with `cargo test --all-features ...`. – rodrigo May 15 '20 at 09:53

1 Answers1

0

Unfortunately there isn't any option which can help in specifying automatic features for profiles.

You can make aliases in your shell for running those repeated commands or better yet, use Just which is an amazing command runner written in Rust.

Arijit Dey
  • 316
  • 2
  • 10