Skip to content

Emit warning when using --shard-count (> 1) with --order rand - #3186

Open
mattyrazz7 wants to merge 1 commit into
catchorg:develfrom
mattyrazz7:bugfix/warn-on-sharding-with-rand
Open

Emit warning when using --shard-count (> 1) with --order rand#3186
mattyrazz7 wants to merge 1 commit into
catchorg:develfrom
mattyrazz7:bugfix/warn-on-sharding-with-rand

Conversation

@mattyrazz7

Copy link
Copy Markdown

Description

Using sharding with the default test ordering (--order rand) doesn't behave properly since each --shard-index invocation obtains a freshly reordered set, resulting in duplication and omitted tests. This can be fixed by changing the test ordering or using a fixed random seed between invocations, but it's surprising default behavior.

Change

Mitigate by emitting a warning when the following conditions are met:

  • --shard-count > 1
  • AND --order is rand
  • AND --rng-seed is set to time or random-device

The warning points users to either set --order decl, --order lex, or pass a fixed value to --rng-seed.

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.14%. Comparing base (8b08d4d) to head (0aad6b3).

Additional details and impacted files
@@            Coverage Diff             @@
##            devel    #3186      +/-   ##
==========================================
- Coverage   91.14%   91.14%   -0.00%     
==========================================
  Files         204      204              
  Lines        8942     8950       +8     
==========================================
+ Hits         8150     8157       +7     
- Misses        792      793       +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mattyrazz7
mattyrazz7 force-pushed the bugfix/warn-on-sharding-with-rand branch from 44dc3cc to 0aad6b3 Compare July 31, 2026 20:01
Comment thread tests/ExtraTests/CMakeLists.txt Outdated
)
set_tests_properties(TestSharding::NoWarningOnRandomOrderWithFixedSeed
PROPERTIES
FAIL_REGULAR_EXPRESSION "Warning: using sharding \\(--shard-count\\) with random order"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be more generic (less specific), so that small rewording of the err. message doesn't break it.

Or have it be a CMake variable that is used by this & and the test above, so that the two tests are guaranteed to be kept in sync.

Comment thread tests/CMakeLists.txt
Comment thread tests/ExtraTests/CMakeLists.txt Outdated
set_tests_properties(TestSharding::NoWarningOnRandomOrderWithFixedSeed
PROPERTIES
FAIL_REGULAR_EXPRESSION "Warning: using sharding \\(--shard-count\\) with random order"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be a test that the warning doesn't fire without rng-seed, but with declaration/alphabetical order.

@horenmar

horenmar commented Aug 2, 2026

Copy link
Copy Markdown
Member

Thanks, this will be useful.

@mattyrazz7
mattyrazz7 force-pushed the bugfix/warn-on-sharding-with-rand branch from 0aad6b3 to b9283fd Compare August 2, 2026 16:27
Comment thread tests/CMakeLists.txt
PROPERTIES
FAIL_REGULAR_EXPRESSION "${CATCH_SHARDING_WARNING_REGEX}"
)
endforeach()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a loop to test both lex and decl, but let me know if you want me to do it another way

Comment thread tests/CMakeLists.txt
PASS_REGULAR_EXPRESSION "Randomness seeded to: 17171717"
)

set(CATCH_SHARDING_WARNING_REGEX "Warning: using sharding .* with random order")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with this to give us more flexibility while still getting the gist of the message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants