[tool] Fix stdin.flush calls on processes started by FakeProcessManager (#151183)

Fixes https://github.com/flutter/flutter/issues/151151
This commit is contained in:
Andrew Kolos 2024-07-02 13:40:06 -07:00 committed by GitHub
parent 4cb6d38492
commit 8acf86d995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -174,6 +174,13 @@ void main() {
expect(stderr, 'stderr'.codeUnits);
expect(stdout, 'stdout'.codeUnits);
});
testWithoutContext('stdin should be flushable (all data written is consumed)', () async {
final FakeProcess process = FakeProcess();
process.stdin.write('hello');
// If nothing is listening to the stdin stream, this test will never complete.
await process.stdin.flush();
});
});
group(FakeProcessManager, () {

View File

@ -160,8 +160,13 @@ class FakeProcess implements io.Process {
}
return exitCode;
}),
_stderr = stderr,
stdin = stdin ?? IOSink(StreamController<List<int>>().sink),
_stderr = stderr,
stdin = stdin ??
IOSink(
StreamController<List<int>>()
..stream.listen((_) {})
..sink,
),
_stdout = stdout,
_completer = completer
{