Commit e3ffa768 authored by James Lin's avatar James Lin Committed by James D. Lin

Update with review feedback from dnfield and jonahwilliams

parent c02b805c
...@@ -113,14 +113,18 @@ Future<void> runCommand(String executable, List<String> arguments, { ...@@ -113,14 +113,18 @@ Future<void> runCommand(String executable, List<String> arguments, {
.where((String line) => removeLine == null || !removeLine(line)) .where((String line) => removeLine == null || !removeLine(line))
.map((String line) => '$line\n') .map((String line) => '$line\n')
.transform(const Utf8Encoder()); .transform(const Utf8Encoder());
if (outputMode == OutputMode.print) { switch (outputMode) {
await Future.wait<void>(<Future<void>>[ case OutputMode.print:
stdout.addStream(stdoutSource), await Future.wait<void>(<Future<void>>[
stderr.addStream(process.stderr), stdout.addStream(stdoutSource),
]); stderr.addStream(process.stderr),
} else { ]);
savedStdout = stdoutSource.toList(); break;
savedStderr = process.stderr.toList(); case OutputMode.capture:
case OutputMode.discard:
savedStdout = stdoutSource.toList();
savedStderr = process.stderr.toList();
break;
} }
final int exitCode = await process.exitCode.timeout(timeout, onTimeout: () { final int exitCode = await process.exitCode.timeout(timeout, onTimeout: () {
...@@ -145,9 +149,14 @@ Future<void> runCommand(String executable, List<String> arguments, { ...@@ -145,9 +149,14 @@ Future<void> runCommand(String executable, List<String> arguments, {
// Print the output when we get unexpected results (unless output was // Print the output when we get unexpected results (unless output was
// printed already). // printed already).
if (outputMode != OutputMode.print) { switch (outputMode) {
stdout.writeln(flattenToString(await savedStdout)); case OutputMode.print:
stderr.writeln(flattenToString(await savedStderr)); break;
case OutputMode.capture:
case OutputMode.discard:
stdout.writeln(flattenToString(await savedStdout));
stderr.writeln(flattenToString(await savedStderr));
break;
} }
print( print(
'$redLine\n' '$redLine\n'
......
...@@ -817,7 +817,7 @@ Future<void> _runFlutterTest(String workingDirectory, { ...@@ -817,7 +817,7 @@ Future<void> _runFlutterTest(String workingDirectory, {
List<String> tests = const <String>[], List<String> tests = const <String>[],
}) async { }) async {
// Support printing output or capturing it for matching, but not both. // Support printing output or capturing it for matching, but not both.
assert(_implies(printOutput, outputChecker == null)); assert(!printOutput || outputChecker == null);
final List<String> args = <String>[ final List<String> args = <String>[
'test', 'test',
...@@ -1009,8 +1009,3 @@ Future<void> _androidGradleTests(String subShard) async { ...@@ -1009,8 +1009,3 @@ Future<void> _androidGradleTests(String subShard) async {
await _runDevicelabTest('module_host_with_custom_build_test', env: env); await _runDevicelabTest('module_host_with_custom_build_test', env: env);
} }
} }
/// Returns true if `p` logically implies `q`, false otherwise.
///
/// If `p` is true, `q` must be true.
bool _implies(bool p, bool q) => !p || q;
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