From 98b3e48ed4e722acb0c4bb897397fc817057b5f6 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Tue, 7 Feb 2023 16:04:23 -0800 Subject: [PATCH] Fix hang on successful dev/bots/analyze.dart (#117660) Fixes #117659 It turns out this was due to the output-suppression timer introduced recently as part of cleaning up the output (#109206); on success, the script would wait 10 minutes for the timeout to expire. This didn't affect CI because this feature doesn't apply in CI (as detected by lack of color on stdout.) Fix the issue by cleaning up the timer on success in the same way as on failure. While here, clean up the final summary messages slightly, and also cut the trailing space that printProgress was leaving on each line. --- dev/bots/analyze.dart | 5 ++--- dev/bots/service_worker_test.dart | 4 ++-- dev/bots/test.dart | 6 ++---- dev/bots/utils.dart | 12 ++++++++++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 304b4068dd..df185c8e15 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -47,10 +47,9 @@ Future main(List arguments) async { printProgress('STARTING ANALYSIS'); await run(arguments); if (hasError) { - printProgress('${bold}Test failed.$reset'); - reportErrorsAndExit(); + reportErrorsAndExit('${bold}Analysis failed.$reset'); } - printProgress('${bold}Analysis successful.$reset'); + reportSuccessAndExit('${bold}Analysis successful.$reset'); } /// Scans [arguments] for an argument of the form `--dart-sdk` or diff --git a/dev/bots/service_worker_test.dart b/dev/bots/service_worker_test.dart index 95d898b915..8454ed648c 100644 --- a/dev/bots/service_worker_test.dart +++ b/dev/bots/service_worker_test.dart @@ -60,9 +60,9 @@ Future main() async { await runWebServiceWorkerTestWithBlockedServiceWorkers(headless: false); if (hasError) { - print('One or more tests failed.'); - reportErrorsAndExit(); + reportErrorsAndExit('${bold}One or more tests failed.$reset'); } + reportSuccessAndExit('${bold}Tests successful.$reset'); } // Regression test for https://github.com/flutter/flutter/issues/109093. diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 388023da8e..bd8f32e2d2 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -271,11 +271,9 @@ Future main(List args) async { system.exit(255); } if (hasError) { - printProgress('${bold}Test failed.$reset'); - reportErrorsAndExit(); + reportErrorsAndExit('${bold}Test failed.$reset'); } - printProgress('${bold}Test successful.$reset'); - system.exit(0); + reportSuccessAndExit('${bold}Test successful.$reset'); } final String _luciBotId = Platform.environment['SWARMING_BOT_ID'] ?? ''; diff --git a/dev/bots/utils.dart b/dev/bots/utils.dart index 91d744d5af..24f0298c4c 100644 --- a/dev/bots/utils.dart +++ b/dev/bots/utils.dart @@ -119,9 +119,17 @@ void resetErrorStatus() { _hideTimer = null; } -Never reportErrorsAndExit() { +Never reportSuccessAndExit(String message) { _hideTimer?.cancel(); _hideTimer = null; + print('$clock $message$reset'); + system.exit(0); +} + +Never reportErrorsAndExit(String message) { + _hideTimer?.cancel(); + _hideTimer = null; + print('$clock $message$reset'); print(redLine); print('${red}For your convenience, the error messages reported above are repeated here:$reset'); final bool printSeparators = _errorMessages.any((List messages) => messages.length > 1); @@ -143,7 +151,7 @@ void printProgress(String message) { _pendingLogs.clear(); _hideTimer?.cancel(); _hideTimer = null; - print('$clock $message $reset'); + print('$clock $message$reset'); if (hasColor) { // This sets up a timer to switch to verbose mode when the tests take too long, // so that if a test hangs we can see the logs.