From b9f013c044d27a03ac430526eb602746a9fa3c46 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Sun, 10 Mar 2019 11:26:17 -0700 Subject: [PATCH] Make sure test reporter prints out stderr, and disables Bigquery for non-contributors (#29073) * print stderr to stderr, no bq if not contributor * let test continue of bigquery fails --- dev/bots/flutter_compact_formatter.dart | 11 +++++++++-- dev/bots/run_command.dart | 1 + dev/bots/test.dart | 25 ++++++++++++++++--------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/dev/bots/flutter_compact_formatter.dart b/dev/bots/flutter_compact_formatter.dart index 912c5a4ae9..6433ab7270 100644 --- a/dev/bots/flutter_compact_formatter.dart +++ b/dev/bots/flutter_compact_formatter.dart @@ -129,9 +129,16 @@ class FlutterCompactFormatter { } break; case 'error': + final String error = decoded['error']; + final String stackTrace = decoded['stackTrace']; if (originalResult != null) { - originalResult.errorMessage = decoded['error']; - originalResult.stackTrace = decoded['stackTrace']; + originalResult.errorMessage = error; + originalResult.stackTrace = stackTrace; + } else { + if (error != null) + stderr.writeln(error); + if (stackTrace != null) + stderr.writeln(stackTrace); } break; case 'print': diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index 2470885102..8cf8322ed4 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart @@ -50,6 +50,7 @@ Stream runAndGetStdout(String executable, List arguments, { environment: environment, ); + stderr.addStream(process.stderr); final Stream lines = process.stdout.transform(utf8.decoder).transform(const LineSplitter()); await for (String line in lines) { yield line; diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 1a8284b384..754ad71354 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -148,17 +148,24 @@ Future _runSmokeTests() async { Future _getBigqueryApi() async { // TODO(dnfield): How will we do this on LUCI? final String privateKey = Platform.environment['GCLOUD_SERVICE_ACCOUNT_KEY']; - if (privateKey == null || privateKey.isEmpty) { + // If we're on Cirrus and a non-collaborator is doing this, we can't get the key. + if (privateKey == null || privateKey.isEmpty || privateKey.startsWith('ENCRYPTED[')) { + return null; + } + try { + final auth.ServiceAccountCredentials accountCredentials = auth.ServiceAccountCredentials( //.fromJson(credentials); + 'flutter-ci-test-reporter@flutter-infra.iam.gserviceaccount.com', + auth.ClientId.serviceAccount('114390419920880060881.apps.googleusercontent.com'), + '-----BEGIN PRIVATE KEY-----\n$privateKey\n-----END PRIVATE KEY-----\n', + ); + final List scopes = [bq.BigqueryApi.BigqueryInsertdataScope]; + final http.Client client = await auth.clientViaServiceAccount(accountCredentials, scopes); + return bq.BigqueryApi(client); + } catch (e) { + print('Failed to get BigQuery API client.'); + print(e); return null; } - final auth.ServiceAccountCredentials accountCredentials = auth.ServiceAccountCredentials( //.fromJson(credentials); - 'flutter-ci-test-reporter@flutter-infra.iam.gserviceaccount.com', - auth.ClientId.serviceAccount('114390419920880060881.apps.googleusercontent.com'), - '-----BEGIN PRIVATE KEY-----\n$privateKey\n-----END PRIVATE KEY-----\n', - ); - final List scopes = [bq.BigqueryApi.BigqueryInsertdataScope]; - final http.Client client = await auth.clientViaServiceAccount(accountCredentials, scopes); - return bq.BigqueryApi(client); } Future _runToolTests() async {