[flutter_tools] Simplify flutter test internals
#74176
Merged
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.
This is a refactoring to simplify how
flutter testruns tests withFlutterTestPlatform.Currently, the tester can crash before and after the test harness connects to the websocket, with the use of
InitialResult. The control flow is nested, resulting in the rough state diagram below:Instead, in this PR, we share the same crash state, which simplifies the logic and makes the workflow easier to reason about.
Other more minor changes:
Watcher?.handleTestCrashedwhen the tester crashes after the harness connects to it, but we do call it when the tester crashes before the harness connects to it. This is fixed here.watcher?.handleStartedProcess(ProcessEvent(ourTestCount, process, processObservatoryUri))whenenableObservatoryis false. The code path is only active when that is enabled, which is fixed here with the refactoring to use a helper method to deal with connecting to the observatory. Because of this, we need to fix thepackage:integration_testtestswhenfrom_getExitCodeMessagefor simplicity, so that we don't have to track the state of the test purely for logging purposes. This doesn't seem useful becausewhenis mainly an implementation detail. When troubleshooting (in verbose mode), the trace messages added would be much more useful in determining the state of the test, and some additional trace messages have been added.InitialResult,TestResult, introduce a private_TestHarnessStatusExisting tests should cover this refactoring.
Related: #66264. This PR will make it easier to decouple
FlutterPlatformfromProcess(#74236)