Skip to content

feat: Lock random seeds in the flutter/tests customer testing run - #4052

Merged
spydon merged 1 commit into
mainfrom
feat/lock-random-seeds-in-customer-testing
Sep 22, 2026
Merged

spydon merged 1 commit into
mainfrom
feat/lock-random-seeds-in-customer-testing

Conversation

@spydon

@spydon spydon commented Sep 22, 2026

Copy link
Copy Markdown
Member

Description

The flutter/tests customer testing run exists to catch regressions in flutter/flutter, so it should be deterministic. Randomized tests with fresh seeds on every run (see #4051 for a recent example) can make it fail for reasons that have nothing to do with the framework change under test.

scripts/customer_testing.dart now passes --dart-define=RANDOM_SEED=<fixed> to flutter test. The RANDOM_SEED define was already read by testRandom in flame_test, but a few things had to change for it to be usable across a whole run:

  • testRandom offsets a fixed seed by the repeat index, so repeatCount: 3 still runs three distinct cases instead of the same one three times. This applies to the seed: parameter as well, and the first repeat still uses the seed as given, so reproducing a failure from the test output works as before.
  • testWidgetsRandom now honors the define too. It previously ignored it.
  • The two tests that created an unseeded Random() directly (the fixed aspect ratio viewport auto-resizing test and the opacity effect fade out test) now seed it through seedFromEnvironment, so they are deterministic under the define and unchanged otherwise.
  • The random_test_test assertion that consecutive seeds differ is skipped when the define is set, since that is exactly what the define turns off. A new test covers the repeat offset behavior.
  • The testing guide documents the define.

Flame's own CI keeps running the randomized tests with fresh seeds, so randomized coverage is unchanged there.

Verified locally with flutter test in flame_test and on the affected flame tests, both with and without --dart-define=RANDOM_SEED=20260922. With the define, the test names show consecutive seeds per repeat and everything passes.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • [-] I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Follow-up to #4051 and flutter/tests#493.

The customer testing script now passes a fixed RANDOM_SEED define to
flutter test so that the run is deterministic. To make that work, the
testRandom helper offsets a fixed seed by the repeat index instead of
reusing it, testWidgetsRandom honors the define too, and the two tests
that created an unseeded Random directly now seed it from the
environment.
@spydon
spydon force-pushed the feat/lock-random-seeds-in-customer-testing branch from 56f90d7 to 5292d88 Compare September 22, 2026 07:16
@spydon
spydon enabled auto-merge (squash) September 22, 2026 07:19
@spydon
spydon merged commit c35f9d8 into main Sep 22, 2026
9 checks passed
@spydon
spydon deleted the feat/lock-random-seeds-in-customer-testing branch September 22, 2026 07:34
spydon added a commit to spydon/tests that referenced this pull request Sep 22, 2026
Picks up flame-engine/flame#4051, which fixes the solveQuadratic random
test tolerance that made the customer test fail for some seeds, and
flame-engine/flame#4052, which pins the randomized tests to a fixed seed
in the customer testing run so it stays deterministic.
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