[go: nahoru, domu]

Skip to content

Commit

Permalink
[tool] Fix stdin.flush calls on processes started by `FakeProcessMa…
Browse files Browse the repository at this point in the history
…nager` (flutter#151183)

Fixes flutter#151151
  • Loading branch information
andrewkolos committed Jul 2, 2024
1 parent 4cb6d38 commit 8acf86d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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, () {
Expand Down
9 changes: 7 additions & 2 deletions packages/flutter_tools/test/src/fake_process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 8acf86d

Please sign in to comment.