From 149c1c21aa87048be5961a578fe677848fc92411 Mon Sep 17 00:00:00 2001 From: Renan Araujo Date: Mon, 16 May 2022 11:40:38 +0100 Subject: [PATCH] fix line output --- lib/src/cli/flutter_cli.dart | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/src/cli/flutter_cli.dart b/lib/src/cli/flutter_cli.dart index 4199d9d1..a53cdd0c 100644 --- a/lib/src/cli/flutter_cli.dart +++ b/lib/src/cli/flutter_cli.dart @@ -182,6 +182,7 @@ class Flutter { ], stdout: stdout ?? noop, stderr: stderr ?? noop, + optimizePerformance: optimizePerformance, ).whenComplete(() { if (optimizePerformance) { File(p.join(cwd, 'test', '.test_runner.dart')).delete().ignore(); @@ -270,6 +271,7 @@ Future _flutterTest({ List? arguments, required void Function(String) stdout, required void Function(String) stderr, + required bool optimizePerformance, }) { const clearLine = '\u001B[2K\r'; @@ -277,10 +279,10 @@ Future _flutterTest({ final suites = {}; final groups = {}; final tests = {}; + final failedTests = []; var successCount = 0; var skipCount = 0; - final failedTests = []; String computeStats() { final passingTests = successCount.formatSuccess(); @@ -347,7 +349,7 @@ Future _flutterTest({ successCount++; } else { stderr('$clearLine${test.name} ${suite.path} (FAILED)'); - failedTests.add(test.name); + failedTests.add(test.id); } final timeElapsed = Duration(milliseconds: event.time).formatted(); @@ -370,17 +372,24 @@ Future _flutterTest({ if (event.success != true) { assert( failedTests.isNotEmpty, - 'Invalid state: test event report as faield but no failed tests were gathered', + 'Invalid state: test event report as faield but no failed tests ' + 'were gathered', ); final title = styleBold.wrap('Failing Tests:'); final lines = failedTests.fold( StringBuffer('$clearLine$title\n'), - (previousValue, testName) { - previousValue.writeln('$clearLine - $testName'); + (previousValue, testId) { + final test = tests[testId]; + if (test != null) { + final suitePath = suites[test.suiteID]?.path ?? ''; + previousValue.writeln( + '$clearLine - $suitePath:${test.line}:${test.column}', + ); + } return previousValue; }, ); - stdout(lines.toString()); + stderr(lines.toString()); } }