Fix coverage shard and print summary after test run (#28970) * Fix coverage shard * clarify * Make sure we print test results * Actually report test results before exiting * revert unintended changes
diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index de90be7..2470885 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart
@@ -37,6 +37,7 @@ int expectedExitCode, String failureMessage, Duration timeout = _kLongTimeout, + Function beforeExit, }) async* { final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}'; final String relativeWorkingDir = path.relative(workingDirectory); @@ -70,6 +71,7 @@ '${bold}Relative working directory:$red $relativeWorkingDir$reset\n' '$redLine' ); + beforeExit?.call(); exit(1); } }
diff --git a/dev/bots/test.dart b/dev/bots/test.dart index ea8bb9b..bb41ead 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart
@@ -358,11 +358,15 @@ pubEnvironment['FLUTTER_TOOL_ARGS'] = toolsArgs.trim(); } - final Stream<String> testOutput = runAndGetStdout(pub, args, + final FlutterCompactFormatter formatter = FlutterCompactFormatter(); + final Stream<String> testOutput = runAndGetStdout( + pub, + args, workingDirectory: workingDirectory, environment: pubEnvironment, + beforeExit: formatter.finish ); - await _processTestOutput(testOutput, tableData); + await _processTestOutput(formatter, testOutput, tableData); } Future<void> _pubRunTest( @@ -388,10 +392,14 @@ toolsArgs += ' --enable-asserts'; pubEnvironment['FLUTTER_TOOL_ARGS'] = toolsArgs.trim(); } - final Stream<String> testOutput = runAndGetStdout(pub, args, + final FlutterCompactFormatter formatter = FlutterCompactFormatter(); + final Stream<String> testOutput = runAndGetStdout( + pub, + args, workingDirectory: workingDirectory, + beforeExit: formatter.finish, ); - await _processTestOutput(testOutput, tableData); + await _processTestOutput(formatter, testOutput, tableData); } enum CiProviders { @@ -460,9 +468,13 @@ return ''; } -Future<void> _processTestOutput(Stream<String> testOutput, bq.TabledataResourceApi tableData) async { - final FlutterCompactFormatter formatter = FlutterCompactFormatter(); +Future<void> _processTestOutput( + FlutterCompactFormatter formatter, + Stream<String> testOutput, + bq.TabledataResourceApi tableData, +) async { await testOutput.forEach(formatter.processRawOutput); + formatter.finish(); if (tableData == null || formatter.tests.isEmpty) { return; } @@ -538,7 +550,8 @@ if (flutterTestArgs != null && flutterTestArgs.isNotEmpty) args.addAll(flutterTestArgs); - if (!expectFailure) { + final bool shouldProcessOutput = !expectFailure && !options.contains('--coverage'); + if (shouldProcessOutput) { args.add('--machine'); } @@ -556,7 +569,7 @@ } args.add(script); } - if (expectFailure) { + if (!shouldProcessOutput) { return runCommand(flutter, args, workingDirectory: workingDirectory, expectNonZeroExit: true, @@ -565,12 +578,14 @@ timeout: timeout, ); } + final FlutterCompactFormatter formatter = FlutterCompactFormatter(); final Stream<String> testOutput = runAndGetStdout(flutter, args, workingDirectory: workingDirectory, expectNonZeroExit: expectFailure, timeout: timeout, + beforeExit: formatter.finish, ); - await _processTestOutput(testOutput, tableData); + await _processTestOutput(formatter, testOutput, tableData); } Future<void> _verifyVersion(String filename) async {