Commit 5f7af56f authored by Dan Rubel's avatar Dan Rubel Committed by GitHub

modify runCommandAndStreamOutput to wait until stdout (#5596)

has been fully processed before completing the returned future.
This helps prevent tests that rely on stdout from being flaky.
parent f1d5fd8c
...@@ -49,7 +49,7 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, { ...@@ -49,7 +49,7 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
allowReentrantFlutter: allowReentrantFlutter allowReentrantFlutter: allowReentrantFlutter
); );
process.stdout StreamSubscription<String> subscription = process.stdout
.transform(UTF8.decoder) .transform(UTF8.decoder)
.transform(const LineSplitter()) .transform(const LineSplitter())
.where((String line) => filter == null ? true : filter.hasMatch(line)) .where((String line) => filter == null ? true : filter.hasMatch(line))
...@@ -74,6 +74,11 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, { ...@@ -74,6 +74,11 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
if (line != null) if (line != null)
printError('$prefix$line'); printError('$prefix$line');
}); });
// Wait for stdout to be fully processed
// because process.exitCode may complete first causing flaky tests.
await subscription.asFuture();
return await process.exitCode; return await process.exitCode;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment