Skip to content

analyze_continuously_test.dart relies on sync I/O #134621

Closed

Description

@dcharkes

In #134523, I tried to convert

return Future<Uint8List>.value(configFile.readAsBytesSync());

to

return configFile.readAsBytes();

However, that leads to a test not terminating:

testUsingContext('AnalysisService --watch skips errors from non-files', () async {
final BufferLogger logger = BufferLogger.test();
final Completer<void> completer = Completer<void>();
final StreamController<List<int>> stdin = StreamController<List<int>>();
final FakeProcessManager processManager = FakeProcessManager.list(
<FakeCommand>[
FakeCommand(
command: const <String>[
'Artifact.engineDartSdkPath/bin/dart',
'--disable-dart-dev',
'Artifact.engineDartSdkPath/bin/snapshots/analysis_server.dart.snapshot',
'--disable-server-feature-completion',
'--disable-server-feature-search',
'--sdk',
'Artifact.engineDartSdkPath',
'--suppress-analytics',
],
stdin: IOSink(stdin.sink),
stdout: '''
{"event":"server.status","params":{"analysis":{"isAnalyzing":true}}}
{"event":"analysis.errors","params":{"file":"/directoryA/bar","errors":[{"type":"TestError","message":"It's an error.","severity":"warning","code":"500","location":{"file":"/directoryA/bar","startLine":100,"startColumn":5,"offset":0}}]}}
{"event":"server.status","params":{"analysis":{"isAnalyzing":false}}}
'''
),
]);
final Artifacts artifacts = Artifacts.test();
final AnalyzeCommand command = AnalyzeCommand(
terminal: Terminal.test(),
artifacts: artifacts,
logger: logger,
platform: FakePlatform(),
fileSystem: MemoryFileSystem.test(),
processManager: processManager,
allProjectValidators: <ProjectValidator>[],
suppressAnalytics: true,
);
await FakeAsync().run((FakeAsync time) async {
final TestFlutterCommandRunner commandRunner = TestFlutterCommandRunner();
commandRunner.addCommand(command);
unawaited(commandRunner.run(<String>['analyze', '--watch']));
while (!logger.statusText.contains('analyzed 1 file')) {
time.flushMicrotasks();
}
completer.complete();
return completer.future;
});
expect(logger.statusText, contains('No issues found!'));
expect(logger.errorText, isEmpty);
expect(processManager, hasNoRemainingExpectations);
});

It's not obvious to me why this test stops terminating.
My hunch is that because the test code is not yielding anywhere, the async I/O never completes. I've tried adding some yield points in various places, but that didn't help.
No other tests fail, so it looks like the failure is localized to this test.

(Not converting this call to async, seems to have minimal to no impact on the speedup in #134523, so we can land that without converting this I/O. I ran into this because I tried to convert all I/O in the relevant Targets to async.)

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    team-toolOwned by Flutter Tool team
    on Sep 19, 2023
  2. added
    P2Important issues not at the top of the work list
    triaged-toolTriaged by Flutter Tool team
    on Sep 19, 2023
  3. added
    tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.
    on Jul 11, 2025
  4. github-actions commented on Sep 23, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: tech-debtTechnical debt, code quality, testing, etc.team-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.tool-still-validIssues that have been deemed still valid as part of the Flutter Tools issue cleanup initiative.triaged-toolTriaged by Flutter Tool team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions