diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index d96abb1be3..93ce567023 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart @@ -113,14 +113,18 @@ Future runCommand(String executable, List arguments, { .where((String line) => removeLine == null || !removeLine(line)) .map((String line) => '$line\n') .transform(const Utf8Encoder()); - if (outputMode == OutputMode.print) { - await Future.wait(>[ - stdout.addStream(stdoutSource), - stderr.addStream(process.stderr), - ]); - } else { - savedStdout = stdoutSource.toList(); - savedStderr = process.stderr.toList(); + switch (outputMode) { + case OutputMode.print: + await Future.wait(>[ + stdout.addStream(stdoutSource), + stderr.addStream(process.stderr), + ]); + break; + case OutputMode.capture: + case OutputMode.discard: + savedStdout = stdoutSource.toList(); + savedStderr = process.stderr.toList(); + break; } final int exitCode = await process.exitCode.timeout(timeout, onTimeout: () { @@ -145,9 +149,14 @@ Future runCommand(String executable, List arguments, { // Print the output when we get unexpected results (unless output was // printed already). - if (outputMode != OutputMode.print) { - stdout.writeln(flattenToString(await savedStdout)); - stderr.writeln(flattenToString(await savedStderr)); + switch (outputMode) { + case OutputMode.print: + break; + case OutputMode.capture: + case OutputMode.discard: + stdout.writeln(flattenToString(await savedStdout)); + stderr.writeln(flattenToString(await savedStderr)); + break; } print( '$redLine\n' diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 6a49654526..2901fc13d3 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -817,7 +817,7 @@ Future _runFlutterTest(String workingDirectory, { List tests = const [], }) async { // Support printing output or capturing it for matching, but not both. - assert(_implies(printOutput, outputChecker == null)); + assert(!printOutput || outputChecker == null); final List args = [ 'test', @@ -1009,8 +1009,3 @@ Future _androidGradleTests(String subShard) async { 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;