Commit 21f57a85 authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Wait for stderr in `runCommandAndStreamOutput()` (#9598)

parent 60c5ffc1
......@@ -102,14 +102,13 @@ Future<Process> runCommand(List<String> cmd, {
String workingDirectory,
bool allowReentrantFlutter: false,
Map<String, String> environment
}) async {
}) {
_traceCommand(cmd, workingDirectory: workingDirectory);
final Process process = await processManager.start(
return processManager.start(
cmd,
workingDirectory: workingDirectory,
environment: _environment(allowReentrantFlutter, environment)
environment: _environment(allowReentrantFlutter, environment),
);
return process;
}
/// This runs the command and streams stdout/stderr from the child process to
......@@ -129,7 +128,7 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
allowReentrantFlutter: allowReentrantFlutter,
environment: environment
);
final StreamSubscription<String> subscription = process.stdout
final StreamSubscription<String> stdoutSubscription = process.stdout
.transform(UTF8.decoder)
.transform(const LineSplitter())
.where((String line) => filter == null ? true : filter.hasMatch(line))
......@@ -144,7 +143,7 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
printStatus(message);
}
});
process.stderr
final StreamSubscription<String> stderrSubscription = process.stderr
.transform(UTF8.decoder)
.transform(const LineSplitter())
.where((String line) => filter == null ? true : filter.hasMatch(line))
......@@ -157,8 +156,12 @@ Future<int> runCommandAndStreamOutput(List<String> cmd, {
// Wait for stdout to be fully processed
// because process.exitCode may complete first causing flaky tests.
await subscription.asFuture<Null>();
subscription.cancel();
await Future.wait(<Future<Null>>[
stdoutSubscription.asFuture<Null>(),
stderrSubscription.asFuture<Null>(),
]);
stdoutSubscription.cancel();
stderrSubscription.cancel();
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