From f070ffc53b00b10a09eed9fd598e4fda0b24a241 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Tue, 3 Sep 2024 14:36:24 -0700 Subject: [PATCH] Get reasonable output when a stream test fails. (#154377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debugging https://github.com/flutter/flutter/issues/154268 was hard; when I removed `--disable-dart-dev` I would get the following error from this test: Screenshot 2024-08-29 at 4 25 43 PM After my change, this is what the error looks like: Screenshot 2024-08-29 at 4 26 50 PM In general we should embrace more of the test package and matchers when appropriate. --- dev/devicelab/test/run_test.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dev/devicelab/test/run_test.dart b/dev/devicelab/test/run_test.dart index e06c55f538..a68af4e01a 100644 --- a/dev/devicelab/test/run_test.dart +++ b/dev/devicelab/test/run_test.dart @@ -80,9 +80,16 @@ void main() { '--no-terminate-stray-dart-processes', '-t', 'smoke_test_setup_failure', ]); - await process.stdout.transform(utf8.decoder).where( - (String line) => line.contains('VM service still not ready. It is possible the target has failed') - ).first; + + // If this test fails, the reason is usually buried in stderr. + final Stream stderr = process.stderr.transform(utf8.decoder); + stderr.listen(printOnFailure); + + final Stream stdout = process.stdout.transform(utf8.decoder); + await expectLater( + stdout, + emitsThrough(contains('VM service still not ready. It is possible the target has failed')), + ); expect(process.kill(), isTrue); });