Repository navigation
[flutter_tools] Fix flaky tool_tests_general by moving spawnUri tests to integration shard - #195999
Conversation
… to integration shard `Mac tool_tests_general` runs general shard tests with a 2-second timeout (`--timeout=2000ms`). In `extension_discovery_test.dart`, `ExtensionConnection.spawnUri` compiles and spawns a real external isolate script (`bin/flutter_tools_extension_linux_prototype.dart`) from disk, which takes 1 to 2.5 seconds on macOS CI bots and intermittently times out. This resolves the flakiness at the root cause: 1. Supports `expectedConfig` validation in `ExtensionConnection.spawn`, allowing capability and manifest drift validation to be tested hermetically in-process in `test/general.shard` without spawning external scripts. 2. Moves real `ExtensionConnection.spawnUri` isolate script execution to `test/integration.shard/tool_extensions_test.dart`, where integration tests belong and run under the standard 15-minute timeout. Previous output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities 00:01 +0 -2: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:01 +0 -2: Some tests failed. Failing tests: test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities Consider enabling the flag chain-stack-traces to receive more detailed exceptions. For example, 'dart test --chain-stack-traces'. ``` Current output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection completes isolate handshake and retrieves capabilities 00:00 +1: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws and cleans up on isolate startup failure 00:00 +2: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service initialize throws 00:00 +3: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service registers duplicate RPC method 00:00 +4: ExtensionDiscovery & Connection Base ExtensionDiscovery registers multiple connections and disposes them 00:00 +5: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson eagerly deserializes lists and normalizes platforms 00:00 +6: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson throws FormatException on invalid field types 00:00 +7: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run rejects duplicate RPC method registration 00:00 +8: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run validates SendPort message 00:00 +9: ExtensionDiscovery & Connection Base ExtensionConnection.spawn completes handshake and matches expectedConfig 00:00 +10: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws StateError when expectedConfig does not match capabilities 00:00 +11: ExtensionDiscovery & Connection Base ToolExtensionService.sendNotification throws StateError before peer attachment 00:00 +12: ExtensionDiscovery & Connection Base sendNotification and onNotification deliver notifications round-trip 00:00 +13: ExtensionDiscovery & Connection Base onNotification supports multiple listeners on broadcast stream 00:00 +14: ExtensionDiscovery & Connection Base onNotification throws StateError after dispose 00:00 +15: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate exits unexpectedly 00:00 +16: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate throws unhandled async error 00:00 +17: All tests passed! ``` Fixes flutter#195966
Resolves merge conflict in `packages/flutter_tools/test/general.shard/extension_protocol/extension_discovery_test.dart`. Also restores the two duplicated `flutter create with custom template` tests in `packages/flutter_tools/test/integration.shard/tool_extensions_test.dart` that the previous commit removed, so this PR only adds to that file.
There was a problem hiding this comment.
Code Review
This pull request refactors the 'ExtensionConnection' class to perform capability validation against 'expectedConfig' directly during the handshake process in '_spawnAndHandshake'. It also updates unit tests to use 'ExtensionConnection.spawn' instead of 'spawnUri'. Feedback indicates that existing integration tests for custom templates in 'tool_extensions_test.dart' were accidentally removed and replaced by a new test, and requests that these tests be restored to maintain test coverage.
…Connection and expand unit tests Makes `_validateCapabilitiesMatchConfig` static and invokes it before constructing `ExtensionConnection._`, avoiding redundant connection creation and nested `dispose()` handling on capability mismatch. Also expands `ExtensionConnection.spawn` unit tests in `extension_discovery_test.dart` with a single-service entrypoint (`_singleServiceEntryPoint`) to exercise non-empty `services` and `hostPlatforms` matching and same-length service mismatch. Previous output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities 00:01 +0 -2: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:01 +0 -2: Some tests failed. Failing tests: test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities Consider enabling the flag chain-stack-traces to receive more detailed exceptions. For example, 'dart test --chain-stack-traces'. ``` Current output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection completes isolate handshake and retrieves capabilities 00:00 +1: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws and cleans up on isolate startup failure 00:00 +2: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service initialize throws 00:00 +3: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service registers duplicate RPC method 00:00 +4: ExtensionDiscovery & Connection Base ExtensionDiscovery registers multiple connections and disposes them 00:00 +5: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson eagerly deserializes lists and normalizes platforms 00:00 +6: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson throws FormatException on invalid field types 00:00 +7: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run rejects duplicate RPC method registration 00:00 +8: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run validates SendPort message 00:00 +9: ExtensionDiscovery & Connection Base ExtensionConnection.spawn completes handshake and matches expectedConfig 00:00 +10: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws StateError when expectedConfig does not match capabilities 00:00 +11: ExtensionDiscovery & Connection Base ToolExtensionService.sendNotification throws StateError before peer attachment 00:00 +12: ExtensionDiscovery & Connection Base sendNotification and onNotification deliver notifications round-trip 00:00 +13: ExtensionDiscovery & Connection Base onNotification supports multiple listeners on broadcast stream 00:00 +14: ExtensionDiscovery & Connection Base onNotification throws StateError after dispose 00:00 +15: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate exits unexpectedly 00:00 +16: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate throws unhandled async error 00:00 +17: All tests passed! ```
…config drift Restores end-to-end `ExtensionConnection.spawnUri` `expectedConfig` mismatch coverage in `test/integration.shard/tool_extensions_test.dart` (moved out of `test/general.shard/extension_protocol/extension_discovery_test.dart` so CFE script compilation does not hit `general.shard`'s 2-second timeout on `Mac tool_tests_general`), expands `ExtensionConnection.spawn` unit tests in `extension_discovery_test.dart` to cover undeclared runtime `services` and `supportedPlatforms` length mismatches, and updates stale doc comments on `ExtensionConnection.spawn` and `ExtensionConnection.spawnUri`. Reproduced deterministically on Linux against the unfixed merge-base using `--timeout=500ms` (tightening `general.shard`'s 2-second per-test timeout): Previous output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:00 +0 -1: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities 00:01 +0 -2: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities [E] TimeoutException after 0:00:00.500000: Test timed out after 0.5 seconds. dart:isolate _RawReceivePort._handleMessage 00:01 +0 -2: Some tests failed. Failing tests: test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri spawns extension script and completes handshake test/general.shard/extension_protocol/extension_discovery_test.dart: ExtensionDiscovery & Connection Base ExtensionConnection.spawnUri throws StateError when expectedConfig does not match capabilities Consider enabling the flag chain-stack-traces to receive more detailed exceptions. For example, 'dart test --chain-stack-traces'. ``` Current output: ``` 00:00 +0: loading test/general.shard/extension_protocol/extension_discovery_test.dart 00:00 +0: ExtensionDiscovery & Connection Base ExtensionConnection completes isolate handshake and retrieves capabilities 00:00 +1: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws and cleans up on isolate startup failure 00:00 +2: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service initialize throws 00:00 +3: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws when service registers duplicate RPC method 00:00 +4: ExtensionDiscovery & Connection Base ExtensionDiscovery registers multiple connections and disposes them 00:00 +5: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson eagerly deserializes lists and normalizes platforms 00:00 +6: ExtensionDiscovery & Connection Base ToolExtensionCapabilities.fromJson throws FormatException on invalid field types 00:00 +7: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run rejects duplicate RPC method registration 00:00 +8: ExtensionDiscovery & Connection Base ToolExtensionEntryPoint.run validates SendPort message 00:00 +9: ExtensionDiscovery & Connection Base ExtensionConnection.spawn completes handshake and matches expectedConfig 00:00 +10: ExtensionDiscovery & Connection Base ExtensionConnection.spawn throws StateError when expectedConfig does not match capabilities 00:00 +11: ExtensionDiscovery & Connection Base ToolExtensionService.sendNotification throws StateError before peer attachment 00:00 +12: ExtensionDiscovery & Connection Base sendNotification and onNotification deliver notifications round-trip 00:00 +13: ExtensionDiscovery & Connection Base onNotification supports multiple listeners on broadcast stream 00:00 +14: ExtensionDiscovery & Connection Base onNotification throws StateError after dispose 00:00 +15: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate exits unexpectedly 00:00 +16: ExtensionDiscovery & Connection Base sendRequest with timeout: null completes with StateError when isolate throws unhandled async error 00:00 +17: All tests passed! ``` Fixes flutter#195966
|
autosubmit label was removed for flutter/flutter/195999, because Pull request flutter/flutter/195999 is not in a mergeable state. |
# Conflicts: # packages/flutter_tools/test/integration.shard/tool_extensions_test.dart
|
autosubmit label was removed for flutter/flutter/195999, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@d8bd864...2f09f96 2026-11-17 [email protected] Analyze every flutter create template, and fix the package_ffi lint (flutter/flutter#196165) 2026-11-17 [email protected] Roll Dart SDK from 50debf3c9757 to 26e38955d9d4 (3 revisions) (flutter/flutter#196772) 2026-11-17 [email protected] Manual roll ICU from b09986242cfb to d3c612f44146 (1 revision) (flutter/flutter#196713) 2026-11-17 [email protected] Roll Skia from 4f6b3a8d8565 to 503a380ebecc (19 revisions) (flutter/flutter#196768) 2026-11-17 [email protected] iOS: Don't mock UIView animations in keyboard spring animation test (flutter/flutter#196755) 2026-11-17 [email protected] [flutter_tools] Preserve index.html across --web-content-hash transitions (flutter/flutter#196491) 2026-11-17 [email protected] Fix TextStyle background color fade-out when lerping to null (flutter/flutter#196153) 2026-11-17 [email protected] Update desktop engine TESTOWNERS (flutter/flutter#196732) 2026-11-17 [email protected] [flutter_tools] Do not copy app-only build type properties onto library plugins (flutter/flutter#196692) 2026-11-17 [email protected] [flutter_tools] Remove service and runner ambient context getters (flutter/flutter#196571) 2026-11-17 [email protected] Bump customer tests (flutter/flutter#196740) 2026-11-17 [email protected] Take customer_testing_flame out of bringup (flutter/flutter#196570) 2026-11-17 [email protected] [devicelab] Read AssetManifest.bin from the APK in flavors_test (flutter/flutter#196736) 2026-11-17 [email protected] [flutter_tools] Fix flaky tool_tests_general by moving spawnUri tests to integration shard (flutter/flutter#195999) 2026-11-17 [email protected] Roll Dart SDK from 3e069c6fdbde to 50debf3c9757 (2 revisions) (flutter/flutter#196706) 2026-11-16 [email protected] [web] Record build finish synchronously in renderScene and fix dropped frame timings (flutter/flutter#195947) 2026-11-16 [email protected] Do not reveal obscured character when input is rejected by inputFormatters (flutter/flutter#195022) 2026-11-16 [email protected] Cla draft follow up: add waiting for response (flutter/flutter#196686) 2026-11-16 [email protected] Roll pub packages (flutter/flutter#196684) 2026-11-16 [email protected] Roll Packages from 015df97 to 4c6a7d3 (8 revisions) (flutter/flutter#196681) 2026-11-16 [email protected] Skip Vulkan impeller_unittests on macOS (flutter/flutter#196282) 2026-11-16 [email protected] Move the task runners out of Flutter Engine (flutter/flutter#196267) 2026-11-16 [email protected] [FGP] Add Flutter assets after AGP's asset merge so dotfiles are pack… (flutter/flutter#196465) 2026-11-16 [email protected] iOS: Add Obj-C model for platform view composition params (flutter/flutter#196498) 2026-11-16 [email protected] [Windows] Normalize Shift key messages with a non-standard scan code (flutter/flutter#193675) 2026-11-16 [email protected] Roll Skia from 118eaff3deb4 to 4f6b3a8d8565 (3 revisions) (flutter/flutter#196672) 2026-11-16 [email protected] Roll Dart SDK from c91e8b6674e2 to 3e069c6fdbde (4 revisions) (flutter/flutter#196669) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] 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
Mac tool_tests_generalruns general shard tests with a 2-second timeout(
--timeout=2000ms). Inextension_discovery_test.dart,ExtensionConnection.spawnUricompiles and spawns a real external isolatescript (
bin/flutter_tools_extension_linux_prototype.dart) from disk, whichtakes 1 to 2.5 seconds on macOS CI bots and intermittently times out.
This resolves the flakiness at the root cause:
expectedConfigvalidation inExtensionConnection.spawn,allowing
expectedConfigcapability validation to be tested hermeticallyin-process in
test/general.shardwithout spawning external scripts.ExtensionConnection.spawnUriisolate script execution andconfig.yamlvalidation totest/integration.shard/tool_extensions_test.dart,where integration tests belong and run under the standard 15-minute timeout.
Previous output (reproduced locally with
--timeout=500ms):Current output:
Part of #190755
Fixes #195663
Fixes #195966
Pre-launch Checklist
///).