Repository navigation
[flutter_tools] Resolve symlinks and fix flakiness in widget preview tests - #191214
Merged
Merged
Conversation
…tests Resolve symbolic links in `PreviewDetector`'s project root directory and ephemeral directories to ensure consistent path matching. Pass the SDK path to `AnalysisContextCollection` to ensure correct SDK resolution in worktrees. Add a 100ms delay in test helpers before triggering file changes to allow the file watcher to fully initialize. Fixes: flutter#189849
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates PreviewDetector to accept Artifacts and configure the AnalysisContextCollection with the engine Dart SDK path. It also resolves symbolic links for the project root and ephemeral directories using a new helper method, and introduces short delays in tests to allow file watchers to initialize. The feedback suggests caching the resolved ephemeral directory paths during initialization to avoid repeated synchronous file system operations on every file watcher event.
…tector Cache resolved ephemeral directory paths during initialization to avoid repeated synchronous disk I/O on each file watcher event.
srawlins
approved these changes
Aug 25, 2026
chingjun
added a commit
to chingjun/flutter
that referenced
this pull request
Nov 7, 2026
preview_detector_graph_test writes a project to the real file system,
watches it, and expects each step's change event in turn. Twice on a Mac
under Bazel the step that restores a file found the previous step's errors
still reported (the Mac tester's run at 458, 11-01; `Mac_arm64
tool_tests_commands` at 546's presubmit, 11-06: "Expected: Set:[] Actual:
Set:[foo.dart, main.dart]" from expectHasNoErrors): a write's second
FSEvents event, analyzed while the file was still invalid, reported under
the next step's expectation. The test's own note anticipates it ("slow on
heavily loaded machines and cause flaky failures"); dev/bots runs the
commands shard one file at a time (forceSingleCore), and the GN builder
was still 2-3% flaky on this family before flutter#191214; under
Bazel eight tests ran beside it on the Mac bot. The next run passed each
time.
The file is `flaky` in commands_shard_hermetic now (Bazel retries it up to
three times, 17 s each) rather than serialized: `exclusive` would put the
nine widget_preview watcher tests on the Mac shard's critical path for an
intermittent failure of one.
chingjun
added a commit
to chingjun/flutter
that referenced
this pull request
Nov 12, 2026
preview_detector_graph_test writes a project to the real file system,
watches it, and expects each step's change event in turn. Twice on a Mac
under Bazel the step that restores a file found the previous step's errors
still reported (the Mac tester's run at 458, 11-01; `Mac_arm64
tool_tests_commands` at 546's presubmit, 11-06: "Expected: Set:[] Actual:
Set:[foo.dart, main.dart]" from expectHasNoErrors): a write's second
FSEvents event, analyzed while the file was still invalid, reported under
the next step's expectation. The test's own note anticipates it ("slow on
heavily loaded machines and cause flaky failures"); dev/bots runs the
commands shard one file at a time (forceSingleCore), and the GN builder
was still 2-3% flaky on this family before flutter#191214; under
Bazel eight tests ran beside it on the Mac bot. The next run passed each
time.
The file is `flaky` in commands_shard_hermetic now (Bazel retries it up to
three times, 17 s each) rather than serialized: `exclusive` would put the
nine widget_preview watcher tests on the Mac shard's critical path for an
intermittent failure of one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PreviewDetector's project root directory and ephemeral directories to ensure consistent path matching.AnalysisContextCollectionto ensure correct SDK resolution in worktrees.Related Issues
Fixes #189849
Tests
packages/flutter_tools/test/commands.shard/hermetic/widget_preview/andpackages/flutter_tools/test/commands.shard/permeable/widget_preview/.