cargo-hack icon indicating copy to clipboard operation
cargo-hack copied to clipboard

Add --random option

Open taiki-e opened this issue 7 months ago • 0 comments

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: https://github.com/taiki-e/cargo-hack/blob/d6b31648b0ee18719ca7b15d0d998e1577a0d3fd/src/features.rs#L232-L236

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 avatar Jul 18 '24 00:07 taiki-e