@@ -23,10 +23,16 @@ File get _flutterBinaryFile => File(
2323 ),
2424 );
2525
26+ /// Whether to print line-by-line subprocess output.
27+ ///
28+ /// Set the `VERBOSE` environment variable to enable streaming output,
29+ /// which is useful for debugging timeouts in CI.
30+ final bool _verbose = Platform .environment.containsKey ('VERBOSE' );
31+
2632/// Runs a flutter command using the correct binary ([_flutterBinaryFile] ) with the given arguments.
2733///
28- /// Streams stdout and stderr to the test output in real time so that
29- /// CI logs show progress even if the process hangs or times out.
34+ /// Streams stdout and stderr to the test output in real time when [_verbose]
35+ /// is true, so CI logs show progress even if the process hangs or times out.
3036Future <ProcessResult > _runFlutterCommand (
3137 List <String > arguments, {
3238 required Directory workingDirectory,
@@ -51,19 +57,22 @@ Future<ProcessResult> _runFlutterCommand(
5157
5258 process.stdout.transform (utf8.decoder).listen ((String data) {
5359 stdoutBuffer.write (data);
54- // Print each line with a prefix so it's easy to identify in CI logs.
55- for (final String line in data.split ('\n ' )) {
56- if (line.isNotEmpty) {
57- print (' [$command ] $line ' );
60+ if (_verbose) {
61+ for (final String line in data.split ('\n ' )) {
62+ if (line.isNotEmpty) {
63+ print (' [$command ] $line ' );
64+ }
5865 }
5966 }
6067 });
6168
6269 process.stderr.transform (utf8.decoder).listen ((String data) {
6370 stderrBuffer.write (data);
64- for (final String line in data.split ('\n ' )) {
65- if (line.isNotEmpty) {
66- print (' [$command ] (stderr) $line ' );
71+ if (_verbose) {
72+ for (final String line in data.split ('\n ' )) {
73+ if (line.isNotEmpty) {
74+ print (' [$command ] (stderr) $line ' );
75+ }
6776 }
6877 }
6978 });
@@ -72,6 +81,10 @@ Future<ProcessResult> _runFlutterCommand(
7281 stopwatch.stop ();
7382 print ('[$command ] completed in ${stopwatch .elapsed } '
7483 '(exit code $exitCode )' );
84+ if (exitCode != 0 && ! _verbose) {
85+ print ('[$command ] stdout:\n $stdoutBuffer ' );
86+ print ('[$command ] stderr:\n $stderrBuffer ' );
87+ }
7588
7689 return ProcessResult (
7790 process.pid,
0 commit comments