Skip to content

Fix a race in an expanded reporter retry test - #2810

Merged
natebosch merged 2 commits into
masterfrom
expanded-retry-test-flake
Oct 28, 2026
Merged

natebosch merged 2 commits into
masterfrom
expanded-retry-test-flake

Conversation

@natebosch

Copy link
Copy Markdown
Member

Fixes a flake in expanded_reporter_test.dart "retry: does not report an
attempt for errors after completion", added in #2801. It failed on master
in https://github.com/dart-lang/test/actions/runs/40722683531/job/122938155175:
the +1: second test ... line was missing and the output went straight to
+0 -1: second test ....

The first test scheduled its error with Future(() { ... }), so the test
isolate raised it right after the test completed. The runner starts the
next test one event-loop turn after it receives the complete message. If
the error message was already queued by then, the first test moved to
failed before the second test started. Both orders are correct output, so
this changes the test rather than the runner.

The second test now triggers the first test's error, using the same
Completer pattern as retry_test.dart. Only the stack trace lines in the
expected output change.

Locally, the old fixture reproduced the CI output in 1 of 40 runs. The new
fixture produced identical output in 60 of 60 runs.

The test "retry: does not report an attempt for errors after completion"
flaked on master: the expected `+1: second test ...` progress line was
missing, and the output went straight to `+0 -1: second test ...`.

The first test scheduled its error with `Future(() { ... })`, so the test
isolate raised it right after the test completed, without waiting for the
runner. The runner starts the next test one event-loop turn after it
receives the `complete` message. If the error message was already queued
by then, the first test moved to failed before the second test started,
and the reporter printed different progress lines. Both orders are correct
reporter output; the test's expectation relied on the race.

Have the second test trigger the first test's error, using the same
`Completer` pattern as `retry_test.dart`. The error can't exist until the
second test is running in the isolate, after the runner has printed its
progress line, and the second test waits a turn so the error arrives before
it completes.

Locally, the old fixture produced the CI output in 1 of 40 runs. The new
fixture produced identical output in 60 of 60 runs.
@natebosch
natebosch marked this pull request as ready for review October 28, 2026 21:51
@natebosch
natebosch requested a review from a team as a code owner October 28, 2026 21:51
@github-actions

Copy link
Copy Markdown

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check (for example, for non-user-visible changes when the package version is already at -wip).

@natebosch
natebosch merged commit 6d74720 into master Oct 28, 2026
71 checks passed
@natebosch
natebosch deleted the expanded-retry-test-flake branch October 28, 2026 22:12
copybara-service Bot pushed a commit to dart-lang/sdk that referenced this pull request Oct 29, 2026
Revisions updated by `dart tools/rev_sdk_deps.dart test`.

test (https://github.com/dart-lang/test/compare/5967927..6d74720):
  6d747209  Wed Oct 28 15:12:45 2026 -0700  Nate Bosch  Fix a race in an expanded reporter retry test (dart-lang/test#2810)
  434cf2fc  Wed Oct 28 09:06:26 2026 -0700  Nate Bosch  Enable incremental migration for argument swap (dart-lang/test#2806)

Change-Id: Ifcb0f113940380b788492f3fed829792ba0b7676
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/570662
Auto-Submit: Nate Bosch <[email protected]>
Reviewed-by: Kevin Moore <[email protected]>
Commit-Queue: Kevin Moore <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants