Test reporter (#28297)

* Wrap test.main with a custom processor
* Report test results to bigquery table
This commit is contained in:
Dan Field
2019-03-06 13:13:45 -08:00
committed by GitHub
parent 427fcebcc5
commit 20e0f13cc9
28 changed files with 565 additions and 91 deletions

View File

@@ -30,6 +30,50 @@ void printProgress(String action, String workingDir, String command) {
print('$arrow $action: cd $cyan$workingDir$reset; $yellow$command$reset');
}
Stream<String> runAndGetStdout(String executable, List<String> arguments, {
String workingDirectory,
Map<String, String> environment,
bool expectNonZeroExit = false,
int expectedExitCode,
String failureMessage,
Duration timeout = _kLongTimeout,
}) async* {
final String commandDescription = '${path.relative(executable, from: workingDirectory)} ${arguments.join(' ')}';
final String relativeWorkingDir = path.relative(workingDirectory);
printProgress('RUNNING', relativeWorkingDir, commandDescription);
final DateTime start = DateTime.now();
final Process process = await Process.start(executable, arguments,
workingDirectory: workingDirectory,
environment: environment,
);
final Stream<String> lines = process.stdout.transform(utf8.decoder).transform(const LineSplitter());
await for (String line in lines) {
yield line;
}
final int exitCode = await process.exitCode.timeout(timeout, onTimeout: () {
stderr.writeln('Process timed out after $timeout');
return expectNonZeroExit ? 0 : 1;
});
print('$clock ELAPSED TIME: $bold${elapsedTime(start)}$reset for $commandDescription in $relativeWorkingDir: ');
if ((exitCode == 0) == expectNonZeroExit || (expectedExitCode != null && exitCode != expectedExitCode)) {
if (failureMessage != null) {
print(failureMessage);
}
print(
'$redLine\n'
'${bold}ERROR:$red Last command exited with $exitCode (expected: ${expectNonZeroExit ? (expectedExitCode ?? 'non-zero') : 'zero'}).$reset\n'
'${bold}Command:$cyan $commandDescription$reset\n'
'${bold}Relative working directory:$red $relativeWorkingDir$reset\n'
'$redLine'
);
exit(1);
}
}
Future<void> runCommand(String executable, List<String> arguments, {
String workingDirectory,
Map<String, String> environment,