Repository navigation
Scope SemanticsTester per test in scrollable_semantics_test - #189800
auto-submit[bot] merged 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors scrollable_semantics_test.dart by removing the shared semantics variable and declaring it locally within each test case. Feedback recommends using addTearDown(semantics.dispose) immediately after instantiating SemanticsTester in all tests to ensure proper cleanup on failure, and suggests changing the single occurrence of var to final for consistency.
|
|
||
| testWidgets('scrollable exposes the correct semantic actions', (WidgetTester tester) async { | ||
| semantics = SemanticsTester(tester); | ||
| final semantics = SemanticsTester(tester); |
There was a problem hiding this comment.
To robustly prevent semantics state from bleeding between tests when a test fails, we should register the disposal using addTearDown(semantics.dispose); immediately after instantiating the tester. If an assertion fails, the rest of the test body is skipped, so any manual semantics.dispose() at the end of the test will not be executed. Using addTearDown ensures that dispose() is called even on test failure. Please apply this pattern to all other tests in this file where SemanticsTester is instantiated.
| final semantics = SemanticsTester(tester); | |
| final semantics = SemanticsTester(tester); | |
| addTearDown(semantics.dispose); |
There was a problem hiding this comment.
addTearDown doesn't work for SemanticsTester: the framework's _verifySemanticsHandlesWereDisposed() runs inside runTest's finally block, before addTearDown callbacks fire
There was a problem hiding this comment.
Oh interesting! Is this a bug? When is it disposed then?
There was a problem hiding this comment.
Ah I see it is disposed at the end of the test. Maybe this is a bug though:
the framework's _verifySemanticsHandlesWereDisposed() runs inside runTest's finally block, before addTearDown callbacks fire
Should we file an issue to see?
|
|
||
| // Semantics on | ||
| semantics = SemanticsTester(tester); | ||
| var semantics = SemanticsTester(tester); |
There was a problem hiding this comment.
Use final instead of var for consistency with other tests in this file, as the semantics variable is not reassigned. Additionally, register its disposal using addTearDown to ensure it is cleaned up even if the test fails.
| var semantics = SemanticsTester(tester); | |
| final semantics = SemanticsTester(tester); | |
| addTearDown(semantics.dispose); |
There was a problem hiding this comment.
var is intentional — the toggle test reassigns semantics (dispose → recreate to turn semantics off then on again), so final won't compile here.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors "scrollable_semantics_test.dart" by removing the top-level "semantics" variable and declaring it locally within each test case. It is recommended to change "var semantics" to "final semantics" in the one test case where it was declared with "var" to maintain consistency and adhere to the Dart style guide.
|
|
||
| // Semantics on | ||
| semantics = SemanticsTester(tester); | ||
| var semantics = SemanticsTester(tester); |
There was a problem hiding this comment.
For consistency with the other tests in this file and to adhere to the Dart style guide (which prefers final for local variables that are not reassigned), please use final instead of var here.
| var semantics = SemanticsTester(tester); | |
| final semantics = SemanticsTester(tester); |
References
- Effective Dart: Style prefers declaring variables as final when they are not reassigned. (link)
e4a1b5b to
cc161d4
Compare
…12318) Manual roll requested by stuartmorgan@google.com flutter/flutter@0f02463...c83f80b 2026-07-29 srawlins@google.com Use super-parameter in two_dimensional_utils (flutter/flutter#189957) 2026-07-29 brunocorona.alcantar@gmail.com Scope SemanticsTester per test in scrollable_semantics_test (flutter/flutter#189800) 2026-07-29 engine-flutter-autoroll@skia.org Roll Skia from d78865e708ad to 70733f74d415 (2 revisions) (flutter/flutter#190168) 2026-07-28 chris@bracken.jp iOS: Fix use-after-free race during shell teardown (flutter/flutter#190132) 2026-07-28 engine-flutter-autoroll@skia.org Roll Skia from 62442d6cf0ec to d78865e708ad (30 revisions) (flutter/flutter#190152) 2026-07-28 30870216+gaaclarke@users.noreply.github.com Made linter more robust to non-utf8 files (flutter/flutter#190012) 2026-07-28 engine-flutter-autoroll@skia.org Roll Packages from 6969329 to 3e63635 (6 revisions) (flutter/flutter#190142) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The test file used a single top-level
SemanticsTester semantics;shared across all tests. That is an anti-pattern: state can bleed between tests if one fails to dispose it.This scopes the
SemanticsTesterlocally within each test instead, removing the shared top-level variable. No behavior change to the tests themselves.Fixes #189799
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on [Discord].