Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/shorebird_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,6 @@ jobs:
# Quick sanity check that Android builds work on macOS too
run: dart test test/android_test.dart --name "can build an apk"
working-directory: packages/shorebird_tests
env:
# Enables streaming subprocess output for debugging timeouts.
VERBOSE: "1"
31 changes: 22 additions & 9 deletions packages/shorebird_tests/test/shorebird_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@ File get _flutterBinaryFile => File(
),
);

/// Whether to print line-by-line subprocess output.
///
/// Set the `VERBOSE` environment variable to enable streaming output,
/// which is useful for debugging timeouts in CI.
final bool _verbose = Platform.environment.containsKey('VERBOSE');

/// Runs a flutter command using the correct binary ([_flutterBinaryFile]) with the given arguments.
///
/// Streams stdout and stderr to the test output in real time so that
/// CI logs show progress even if the process hangs or times out.
/// Streams stdout and stderr to the test output in real time when [_verbose]
/// is true, so CI logs show progress even if the process hangs or times out.
Future<ProcessResult> _runFlutterCommand(
List<String> arguments, {
required Directory workingDirectory,
Expand All @@ -51,19 +57,22 @@ Future<ProcessResult> _runFlutterCommand(

process.stdout.transform(utf8.decoder).listen((String data) {
stdoutBuffer.write(data);
// Print each line with a prefix so it's easy to identify in CI logs.
for (final String line in data.split('\n')) {
if (line.isNotEmpty) {
print(' [$command] $line');
if (_verbose) {
for (final String line in data.split('\n')) {
if (line.isNotEmpty) {
print(' [$command] $line');
}
}
}
});

process.stderr.transform(utf8.decoder).listen((String data) {
stderrBuffer.write(data);
for (final String line in data.split('\n')) {
if (line.isNotEmpty) {
print(' [$command] (stderr) $line');
if (_verbose) {
for (final String line in data.split('\n')) {
if (line.isNotEmpty) {
print(' [$command] (stderr) $line');
}
}
}
});
Expand All @@ -72,6 +81,10 @@ Future<ProcessResult> _runFlutterCommand(
stopwatch.stop();
print('[$command] completed in ${stopwatch.elapsed} '
'(exit code $exitCode)');
if (exitCode != 0 && !_verbose) {
print('[$command] stdout:\n$stdoutBuffer');
print('[$command] stderr:\n$stderrBuffer');
}

return ProcessResult(
process.pid,
Expand Down
Loading