Unverified Commit f67a529e authored by Dan Field's avatar Dan Field Committed by GitHub

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
parent a2d349c4
...@@ -37,6 +37,7 @@ Stream<String> runAndGetStdout(String executable, List<String> arguments, { ...@@ -37,6 +37,7 @@ Stream<String> runAndGetStdout(String executable, List<String> arguments, {
int expectedExitCode, int expectedExitCode,
String failureMessage, String failureMessage,
Duration timeout = _kLongTimeout, Duration timeout = _kLongTimeout,
Function beforeExit,
}) async* { }) async* {
final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}'; final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}';
final String relativeWorkingDir = path.relative(workingDirectory); final String relativeWorkingDir = path.relative(workingDirectory);
...@@ -70,6 +71,7 @@ Stream<String> runAndGetStdout(String executable, List<String> arguments, { ...@@ -70,6 +71,7 @@ Stream<String> runAndGetStdout(String executable, List<String> arguments, {
'${bold}Relative working directory:$red $relativeWorkingDir$reset\n' '${bold}Relative working directory:$red $relativeWorkingDir$reset\n'
'$redLine' '$redLine'
); );
beforeExit?.call();
exit(1); exit(1);
} }
} }
......
...@@ -358,11 +358,15 @@ Future<void> _buildRunnerTest( ...@@ -358,11 +358,15 @@ Future<void> _buildRunnerTest(
pubEnvironment['FLUTTER_TOOL_ARGS'] = toolsArgs.trim(); 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, workingDirectory: workingDirectory,
environment: pubEnvironment, environment: pubEnvironment,
beforeExit: formatter.finish
); );
await _processTestOutput(testOutput, tableData); await _processTestOutput(formatter, testOutput, tableData);
} }
Future<void> _pubRunTest( Future<void> _pubRunTest(
...@@ -388,10 +392,14 @@ Future<void> _pubRunTest( ...@@ -388,10 +392,14 @@ Future<void> _pubRunTest(
toolsArgs += ' --enable-asserts'; toolsArgs += ' --enable-asserts';
pubEnvironment['FLUTTER_TOOL_ARGS'] = toolsArgs.trim(); 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, workingDirectory: workingDirectory,
beforeExit: formatter.finish,
); );
await _processTestOutput(testOutput, tableData); await _processTestOutput(formatter, testOutput, tableData);
} }
enum CiProviders { enum CiProviders {
...@@ -460,9 +468,13 @@ String _getGitHash() { ...@@ -460,9 +468,13 @@ String _getGitHash() {
return ''; return '';
} }
Future<void> _processTestOutput(Stream<String> testOutput, bq.TabledataResourceApi tableData) async { Future<void> _processTestOutput(
final FlutterCompactFormatter formatter = FlutterCompactFormatter(); FlutterCompactFormatter formatter,
Stream<String> testOutput,
bq.TabledataResourceApi tableData,
) async {
await testOutput.forEach(formatter.processRawOutput); await testOutput.forEach(formatter.processRawOutput);
formatter.finish();
if (tableData == null || formatter.tests.isEmpty) { if (tableData == null || formatter.tests.isEmpty) {
return; return;
} }
...@@ -538,7 +550,8 @@ Future<void> _runFlutterTest(String workingDirectory, { ...@@ -538,7 +550,8 @@ Future<void> _runFlutterTest(String workingDirectory, {
if (flutterTestArgs != null && flutterTestArgs.isNotEmpty) if (flutterTestArgs != null && flutterTestArgs.isNotEmpty)
args.addAll(flutterTestArgs); args.addAll(flutterTestArgs);
if (!expectFailure) { final bool shouldProcessOutput = !expectFailure && !options.contains('--coverage');
if (shouldProcessOutput) {
args.add('--machine'); args.add('--machine');
} }
...@@ -556,7 +569,7 @@ Future<void> _runFlutterTest(String workingDirectory, { ...@@ -556,7 +569,7 @@ Future<void> _runFlutterTest(String workingDirectory, {
} }
args.add(script); args.add(script);
} }
if (expectFailure) { if (!shouldProcessOutput) {
return runCommand(flutter, args, return runCommand(flutter, args,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
expectNonZeroExit: true, expectNonZeroExit: true,
...@@ -565,12 +578,14 @@ Future<void> _runFlutterTest(String workingDirectory, { ...@@ -565,12 +578,14 @@ Future<void> _runFlutterTest(String workingDirectory, {
timeout: timeout, timeout: timeout,
); );
} }
final FlutterCompactFormatter formatter = FlutterCompactFormatter();
final Stream<String> testOutput = runAndGetStdout(flutter, args, final Stream<String> testOutput = runAndGetStdout(flutter, args,
workingDirectory: workingDirectory, workingDirectory: workingDirectory,
expectNonZeroExit: expectFailure, expectNonZeroExit: expectFailure,
timeout: timeout, timeout: timeout,
beforeExit: formatter.finish,
); );
await _processTestOutput(testOutput, tableData); await _processTestOutput(formatter, testOutput, tableData);
} }
Future<void> _verifyVersion(String filename) async { Future<void> _verifyVersion(String filename) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment