Skip to content

Commit

Permalink
fix line output
Browse files Browse the repository at this point in the history
  • Loading branch information
Renan Araujo committed May 16, 2022
1 parent aa93176 commit 149c1c2
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/src/cli/flutter_cli.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -270,17 +271,18 @@ Future<int> _flutterTest({
List<String>? arguments,
required void Function(String) stdout,
required void Function(String) stderr,
required bool optimizePerformance,
}) {
const clearLine = '\u001B[2K\r';

final completer = Completer<int>();
final suites = <int, TestSuite>{};
final groups = <int, TestGroup>{};
final tests = <int, Test>{};
final failedTests = <int>[];

var successCount = 0;
var skipCount = 0;
final failedTests = <String>[];

String computeStats() {
final passingTests = successCount.formatSuccess();
Expand Down Expand Up @@ -347,7 +349,7 @@ Future<int> _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();
Expand All @@ -370,17 +372,24 @@ Future<int> _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>(
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());
}
}

Expand Down

0 comments on commit 149c1c2

Please sign in to comment.