Skip to content
New issue

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

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

Already on GitHub? # to your account

feature foo needs feature bar #43

Open
LuckyTurtleDev opened this issue May 11, 2023 · 2 comments · May be fixed by #50 or #52
Open

feature foo needs feature bar #43

LuckyTurtleDev opened this issue May 11, 2023 · 2 comments · May be fixed by #50 or #52

Comments

@LuckyTurtleDev
Copy link

I have a feature foo which required also feature bar to be enabled.
It looks like this can not be tested with cargo-all-feautures currently.

At the moment you can skip all combination of feature

skip_feature_sets = [
    ["foo", "bar"],
]

But I can not do something like this:

skip_feature_sets = [
    ["foo", "!bar"],
]

Alternative a new deps field can be added:

[[deps]]
  feature = "foo"
  needs = ["bar"]
@demmerichs
Copy link
Contributor

You can do this already by specifying this dependency in the feature section of Cargo.toml, e.g.

[features]
foo = ["bar"]
bar = []

In the construction of the feature set matrix, this dependency is currently not taken into account (see discussion in #25), and the sets [foo] and [foo, bar] will both be tested even though the activated features in both cases are the same because of the feature dependency that cargo resolves before actually testing/building.

If you want this dependency not for your crate, but only for the testing matrix, then this is currently not possible, but I am working on a PR that will add more flexibility of restricting the feature matrix.

demmerichs added a commit to demmerichs/cargo-all-features that referenced this issue Sep 5, 2023
…e selected feature sets

Fixes frewsxcv#25. Fixes frewsxcv#43.

BREAKING CHANGE: As previously feature sets [B], [A,B] were included separatly, now there will only be [A,B] run if A is a dependency of B. The testcase [B] is redundant, as it activates feature A automatically.
@demmerichs
Copy link
Contributor

I created now the PR #50, which would allow to specify this dependency only for the purpose of testing:

[package.metadata.cargo-all-features]
rules = [
    "bar => foo"
]

See README in that PR for more details on this feature.

demmerichs added a commit to demmerichs/cargo-all-features that referenced this issue Sep 17, 2023
…e selected feature sets

Fixes frewsxcv#25. Fixes frewsxcv#43. Even though cargo activates dependent features automatically, we can reduce
the amount of feature sets when already resolving these dependencies during creation of all feature sets.
We decide to go for the more verbose option, selecting [A, B] over [B] when A is a feature dependency of B.
This allows an easier implementation, as dependency chains C -> B -> A can be verified one by one, and it takes other rules like
skip_feature_sets correctly into account without modification.

BREAKING CHANGE: As previously feature sets [B], [A,B] were included separatly, now there will only be [A,B] run if A is a dependency of B. The testcase [B] is redundant, as it activates feature A automatically.
demmerichs added a commit to demmerichs/cargo-all-features that referenced this issue Sep 17, 2023
…e selected feature sets

Fixes frewsxcv#25. Fixes frewsxcv#43. Even though cargo activates dependent features automatically, we can reduce
the amount of feature sets when already resolving these dependencies during creation of all feature sets.
We decide to go for the more verbose option, selecting [A, B] over [B] when A is a feature dependency of B.
This allows an easier implementation, as dependency chains C -> B -> A can be verified one by one, and it takes other rules like
skip_feature_sets correctly into account without modification.

BREAKING CHANGE: As previously feature sets [B], [A,B] were included separatly, now there will only be [A,B] run if A is a dependency of B. The testcase [B] is redundant, as it activates feature A automatically.
demmerichs added a commit to demmerichs/cargo-all-features that referenced this issue Sep 18, 2023
…e selected feature sets

Fixes frewsxcv#25. Fixes frewsxcv#43. Even though cargo activates dependent features automatically, we can reduce
the amount of feature sets when already resolving these dependencies during creation of all feature sets.
We decide to go for the more verbose option, selecting [A, B] over [B] when A is a feature dependency of B.
This allows an easier implementation, as dependency chains C -> B -> A can be verified one by one, and it takes other rules like
skip_feature_sets correctly into account without modification.

BREAKING CHANGE: As previously feature sets [B], [A,B] were included separatly, now there will only be [A,B] run if A is a dependency of B. The testcase [B] is redundant, as it activates feature A automatically.
@demmerichs demmerichs linked a pull request Sep 18, 2023 that will close this issue
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants