From dce18b6fd9d0310b9016ddb383b8e21b9e065ae2 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 6 May 2025 23:43:07 +0000 Subject: [PATCH] Capture errors when running flutter_tools in the entrypoint_dart_registrant devicelab test (#168411) See https://github.com/flutter/flutter/issues/168405 --- .../lib/tasks/entrypoint_dart_registrant.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart b/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart index 83971f2590a..b07bce22a4e 100644 --- a/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart +++ b/dev/devicelab/lib/tasks/entrypoint_dart_registrant.dart @@ -72,8 +72,19 @@ Future _runWithTempDir(Directory tempDir) async { completer.complete(line); } }); - final String entrypoint = await completer.future; + final StreamSubscription stderrSub = process.stderr + .transform(const Utf8Decoder()) + .transform(const LineSplitter()) + .listen((String line) async { + print(line); + }); + final Object result = await Future.any(>[completer.future, process.exitCode]); + if (result is int) { + throw Exception('flutter run failed, exitCode=$result'); + } + final String entrypoint = result as String; await stdoutSub.cancel(); + await stderrSub.cancel(); process.stdin.write('q'); await process.stdin.flush(); process.kill(ProcessSignal.sigint);