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

Add --random option #255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add --random option #255

wants to merge 1 commit into from

Conversation

taiki-e
Copy link
Owner

@taiki-e taiki-e commented Jul 18, 2024

Originally proposed by @orlp. https://discord.com/channels/273534239310479360/273541522815713281/1263250421653438625

        --random <NUM_SAMPLES>
            Performs with random feature combinations up to the number specified per crate.

            This flag can only be used together with --feature-powerset flag.

There are a few things missing as I have just roughly implemented the idea:

cargo-hack/src/features.rs

Lines 232 to 236 in d6b3164

// TODO:
// - If duplicates are found, they should be de-duplicated and regenerated.
// - Same for filtered case.
// - If the total number of possible combinations is less than num_samples,
// then we should use normal powerset().

Example:

$ cargo hack check --feature-powerset --no-dev-deps --optional-deps --random 10
info: --no-dev-deps modifies real `Cargo.toml` while cargo-hack is running and restores it when finished
info: running `cargo check --no-default-features --features b,c,default,member1` on real (1/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.04s

info: running `cargo check --no-default-features --features c,default` on real (2/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

info: running `cargo check --no-default-features --features a,b,default,member1` on real (3/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s

info: running `cargo check --no-default-features --features c,default` on real (4/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

info: running `cargo check --no-default-features --features default,member1` on real (5/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s

info: running `cargo check --no-default-features --features a,b` on real (6/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

info: running `cargo check --no-default-features --features c` on real (7/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s

info: running `cargo check --no-default-features --features a,b,c,member1` on real (8/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.03s

info: running `cargo check --no-default-features --features a,c,default` on real (9/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

info: running `cargo check --no-default-features --features a,b,default` on real (10/10)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s

@taiki-e taiki-e added the A-features Area: features (--feature-powerset, --each-feature, etc.) label Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features Area: features (--feature-powerset, --each-feature, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant