Skip to content

testing: shuffle seed should be different when -shuffle=on and -count flag is set #61256

@cristaloleg

Description

@cristaloleg

This proposal is a clarification of the original test shuffle flag proposal #28592

Today I was debugging tests that were rarely failing due to cross-dependency between test functions. To verify the fix I noticed that go test -shuffle=on -count=100 runs tests in the same order as the first iteration. In other words -test.shuffle value is generated once and is reused for the other 99 test runs.

This makes sense when the shuffle seed is set explicitly (-shuffle=X ) but for random value (-shuffle=on) we should generate a new one to increase test order randomness to cover more combinations.

Current documentation for count and shuffle flags doesn't mention their relation, so the proposal (if accepted) will not break go test behaviour (docs from current master branch):

//	-count n
//	    Run each test, benchmark, and fuzz seed n times (default 1).
//	    If -cpu is set, run n times for each GOMAXPROCS value.
//	    Examples are always run once. -count does not apply to
//	    fuzz tests matched by -fuzz.
//

...

//
//	-shuffle off,on,N
//	    Randomize the execution order of tests and benchmarks.
//	    It is off by default. If -shuffle is set to on, then it will seed
//	    the randomizer using the system clock. If -shuffle is set to an
//	    integer N, then N will be used as the seed value. In both cases,
//	    the seed will be reported for reproducibility.
//

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Accepted

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions