Skip to content

Commit

Permalink
Fix flush issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia committed Jun 14, 2022
1 parent 01fa07c commit 346adc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
5 changes: 4 additions & 1 deletion testing/scenario_app/bin/android_integration_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ void main(List<String> args) async {
});

late Process logcatProcess;
late Future<int> logcatProcessExitCode;

final IOSink logcat = File(logcatPath).openWrite();
try {
await step('Creating screenshot directory...', () async {
Expand All @@ -103,7 +105,7 @@ void main(List<String> args) async {
panic(<String>['could not clear logs']);
}
logcatProcess = await pm.start(<String>[adb.path, 'logcat', '-T', '1']);
unawaited(pipeProcessStreams(logcatProcess, out: logcat));
logcatProcessExitCode = pipeProcessStreams(logcatProcess, out: logcat);
});

await step('Configuring emulator...', () async {
Expand Down Expand Up @@ -209,6 +211,7 @@ void main(List<String> args) async {
await step('Killing logcat process...', () async {
final bool delivered = logcatProcess.kill(ProcessSignal.sigkill);
assert(delivered);
await logcatProcessExitCode;
});

await step('Wait for Skia gold comparisons...', () async {
Expand Down
15 changes: 2 additions & 13 deletions testing/scenario_app/bin/utils/process_manager_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,25 @@ import 'package:process/process.dart';

/// Pipes the [process] streams and writes them to [out] sink.
/// If [out] is null, then the current [Process.stdout] is used as the sink.
/// If [includePrefix] is true, then the prefix `[stdout]` or `[stderr]` is
/// added before writting to the [out] sink.
Future<int> pipeProcessStreams(
Process process, {
StringSink? out,
bool includePrefix = true,
}) async {
out ??= stdout;
final Completer<void> stdoutCompleter = Completer<void>();
final StreamSubscription<String> stdoutSub = process.stdout
.transform(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) {
if (includePrefix) {
out!.writeln('[stdout] $line');
} else {
out!.writeln(line);
}
out!.writeln('[stdout] $line');
}, onDone: stdoutCompleter.complete);

final Completer<void> stderrCompleter = Completer<void>();
final StreamSubscription<String> stderrSub = process.stderr
.transform(utf8.decoder)
.transform<String>(const LineSplitter())
.listen((String line) {
if (includePrefix) {
out!.writeln('[stderr] $line');
} else {
out!.writeln(line);
}
out!.writeln('[stderr] $line');
}, onDone: stderrCompleter.complete);

final int exitCode = await process.exitCode;
Expand Down

0 comments on commit 346adc0

Please sign in to comment.