Skip to content

Random test ordering for cargo test #85440

Open
@stchris

Description

@stchris

Describe the problem you are trying to solve
Sometimes tests depend on each other and one of the possible counter measures is to shuffle the order in which tests are run.

Describe the solution you'd like
I would like cargo test to take a --random flag, which would shuffle the test order. Ideally it would generate and print the seed used (a u64 integer). This could be used to debug situations, maybe with a corresponding --random-seed <seed> parameter (which would imply --random).

Notes
I had a look at the codebase and I think I identified the place where the sorting currently happens (https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_test.rs#L67). I'd be happy to try to contribute a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libtestArea: `#[test]` / the `test` libraryC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions