Add timestamps to various test logging utilities (#9319)
diff --git a/packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart b/packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart index 21305bf..7f7a11f 100644 --- a/packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart +++ b/packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart
@@ -346,7 +346,7 @@ Future<int> stop({Future<int>? onTimeout}) async { await manuallyStopApp(); - _debugPrint('Waiting for process to end'); + _debugPrint('Waiting for app process to end'); return runProcess!.exitCode.timeout( IOMixin.killTimeout, onTimeout: () =>
diff --git a/packages/devtools_app/integration_test/test_infra/run/_utils.dart b/packages/devtools_app/integration_test/test_infra/run/_utils.dart index ebf1e03..3682008 100644 --- a/packages/devtools_app/integration_test/test_infra/run/_utils.dart +++ b/packages/devtools_app/integration_test/test_infra/run/_utils.dart
@@ -6,8 +6,8 @@ bool debugTestScript = false; -void debugLog(String log) { +void debugLog(String message) { if (debugTestScript) { - print(log); + print('${DateTime.now()}: $message'); } }
diff --git a/packages/devtools_shared/lib/src/test/chrome_driver.dart b/packages/devtools_shared/lib/src/test/chrome_driver.dart index 556062b..be78cc9 100644 --- a/packages/devtools_shared/lib/src/test/chrome_driver.dart +++ b/packages/devtools_shared/lib/src/test/chrome_driver.dart
@@ -19,8 +19,9 @@ const chromedriverExe = 'chromedriver'; const chromedriverArgs = ['--port=4444']; if (debugLogging) { - print('starting the chromedriver process'); - print('> $chromedriverExe ${chromedriverArgs.join(' ')}'); + print('${DateTime.now()}: starting the chromedriver process'); + print('${DateTime.now()}: > $chromedriverExe ' + '${chromedriverArgs.join(' ')}'); } final process = _process = await Process.start( chromedriverExe, @@ -42,7 +43,7 @@ await cancelAllStreamSubscriptions(); if (debugLogging) { - print('killing the chromedriver process'); + print('${DateTime.now()}: killing the chromedriver process'); } await killGracefully(process, debugLogging: debugLogging); }
diff --git a/packages/devtools_shared/lib/src/test/integration_test_runner.dart b/packages/devtools_shared/lib/src/test/integration_test_runner.dart index 3f6faae..6c7dd67 100644 --- a/packages/devtools_shared/lib/src/test/integration_test_runner.dart +++ b/packages/devtools_shared/lib/src/test/integration_test_runner.dart
@@ -30,8 +30,8 @@ List<String> dartDefineArgs = const <String>[], bool debugLogging = false, }) async { - void debugLog(String log) { - if (debugLogging) print(log); + void debugLog(String message) { + if (debugLogging) print('${DateTime.now()}: $message'); } Future<void> runTest({required int attemptNumber}) async { @@ -146,7 +146,9 @@ 'Integration test timed out on try #$attemptNumber. Retrying ' '$testTarget now.', ); - await runTest(attemptNumber: ++attemptNumber); + attemptNumber++; + debugLog('running the test (attempt $attemptNumber)'); + await runTest(attemptNumber: attemptNumber); } } @@ -156,6 +158,7 @@ } } + debugLog('running the test (attempt 1)'); await runTest(attemptNumber: 0); } } @@ -300,8 +303,8 @@ return; } - void debugLog(String log) { - if (debugLogging) print(log); + void debugLog(String message) { + if (debugLogging) print('${DateTime.now()}: $message'); } final chromedriver = ChromeDriver();
diff --git a/packages/devtools_shared/lib/src/test/io_utils.dart b/packages/devtools_shared/lib/src/test/io_utils.dart index ba752b3..65180fe 100644 --- a/packages/devtools_shared/lib/src/test/io_utils.dart +++ b/packages/devtools_shared/lib/src/test/io_utils.dart
@@ -83,22 +83,22 @@ final processId = process.pid; if (debugLogging) { print( - 'Cancelling all stream subscriptions for process $processId before ' - 'killing.', + '${DateTime.now()}: Cancelling all stream subscriptions for process ' + '$processId before killing.', ); } await cancelAllStreamSubscriptions(); if (debugLogging) { - print('Sending SIGTERM to $processId.'); + print('${DateTime.now()}: Sending SIGTERM to $processId.'); } Process.killPid(processId); return process.exitCode.timeout( killTimeout, - onTimeout: () => killForcefully(process, debugLogging: debugLogging), + onTimeout: () => _killForcefully(process, debugLogging: debugLogging), ); } - Future<int> killForcefully( + Future<int> _killForcefully( Process process, { bool debugLogging = false, }) { @@ -106,7 +106,7 @@ // Use sigint here instead of sigkill. See // https://github.com/flutter/flutter/issues/117415. if (debugLogging) { - print('Sending SIGINT to $processId.'); + print('${DateTime.now()}: Sending SIGINT to $processId.'); } Process.killPid(processId, ProcessSignal.sigint); return process.exitCode;
diff --git a/packages/devtools_test/lib/src/helpers/utils.dart b/packages/devtools_test/lib/src/helpers/utils.dart index 12d155b..2ff7fe5 100644 --- a/packages/devtools_test/lib/src/helpers/utils.dart +++ b/packages/devtools_test/lib/src/helpers/utils.dart
@@ -240,7 +240,7 @@ return retryUntilFound(finder, tester: tester, retries: retries - 1); } -void logStatus(String log) { +void logStatus(String message) { // ignore: avoid_print, intentional print for test output - print('TEST STATUS: $log'); + print('${DateTime.now()}: TEST STATUS: $message'); }