Skip to content

Commit 879d56e

Browse files
authored
Add timestamps to various test logging utilities (#9319)
1 parent 7ad4173 commit 879d56e

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

packages/devtools_app/integration_test/test_infra/run/_test_app_driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ abstract class IntegrationTestApp with IOMixin {
346346

347347
Future<int> stop({Future<int>? onTimeout}) async {
348348
await manuallyStopApp();
349-
_debugPrint('Waiting for process to end');
349+
_debugPrint('Waiting for app process to end');
350350
return runProcess!.exitCode.timeout(
351351
IOMixin.killTimeout,
352352
onTimeout: () =>

packages/devtools_app/integration_test/test_infra/run/_utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
bool debugTestScript = false;
88

9-
void debugLog(String log) {
9+
void debugLog(String message) {
1010
if (debugTestScript) {
11-
print(log);
11+
print('${DateTime.now()}: $message');
1212
}
1313
}

packages/devtools_shared/lib/src/test/chrome_driver.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class ChromeDriver with IOMixin {
1919
const chromedriverExe = 'chromedriver';
2020
const chromedriverArgs = ['--port=4444'];
2121
if (debugLogging) {
22-
print('starting the chromedriver process');
23-
print('> $chromedriverExe ${chromedriverArgs.join(' ')}');
22+
print('${DateTime.now()}: starting the chromedriver process');
23+
print('${DateTime.now()}: > $chromedriverExe '
24+
'${chromedriverArgs.join(' ')}');
2425
}
2526
final process = _process = await Process.start(
2627
chromedriverExe,
@@ -42,7 +43,7 @@ class ChromeDriver with IOMixin {
4243
await cancelAllStreamSubscriptions();
4344

4445
if (debugLogging) {
45-
print('killing the chromedriver process');
46+
print('${DateTime.now()}: killing the chromedriver process');
4647
}
4748
await killGracefully(process, debugLogging: debugLogging);
4849
}

packages/devtools_shared/lib/src/test/integration_test_runner.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class IntegrationTestRunner with IOMixin {
3030
List<String> dartDefineArgs = const <String>[],
3131
bool debugLogging = false,
3232
}) async {
33-
void debugLog(String log) {
34-
if (debugLogging) print(log);
33+
void debugLog(String message) {
34+
if (debugLogging) print('${DateTime.now()}: $message');
3535
}
3636

3737
Future<void> runTest({required int attemptNumber}) async {
@@ -146,7 +146,9 @@ class IntegrationTestRunner with IOMixin {
146146
'Integration test timed out on try #$attemptNumber. Retrying '
147147
'$testTarget now.',
148148
);
149-
await runTest(attemptNumber: ++attemptNumber);
149+
attemptNumber++;
150+
debugLog('running the test (attempt $attemptNumber)');
151+
await runTest(attemptNumber: attemptNumber);
150152
}
151153
}
152154

@@ -156,6 +158,7 @@ class IntegrationTestRunner with IOMixin {
156158
}
157159
}
158160

161+
debugLog('running the test (attempt 1)');
159162
await runTest(attemptNumber: 0);
160163
}
161164
}
@@ -300,8 +303,8 @@ Future<void> runOneOrManyTests<T extends IntegrationTestRunnerArgs>({
300303
return;
301304
}
302305

303-
void debugLog(String log) {
304-
if (debugLogging) print(log);
306+
void debugLog(String message) {
307+
if (debugLogging) print('${DateTime.now()}: $message');
305308
}
306309

307310
final chromedriver = ChromeDriver();

packages/devtools_shared/lib/src/test/io_utils.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,30 @@ mixin IOMixin {
8383
final processId = process.pid;
8484
if (debugLogging) {
8585
print(
86-
'Cancelling all stream subscriptions for process $processId before '
87-
'killing.',
86+
'${DateTime.now()}: Cancelling all stream subscriptions for process '
87+
'$processId before killing.',
8888
);
8989
}
9090
await cancelAllStreamSubscriptions();
9191
if (debugLogging) {
92-
print('Sending SIGTERM to $processId.');
92+
print('${DateTime.now()}: Sending SIGTERM to $processId.');
9393
}
9494
Process.killPid(processId);
9595
return process.exitCode.timeout(
9696
killTimeout,
97-
onTimeout: () => killForcefully(process, debugLogging: debugLogging),
97+
onTimeout: () => _killForcefully(process, debugLogging: debugLogging),
9898
);
9999
}
100100

101-
Future<int> killForcefully(
101+
Future<int> _killForcefully(
102102
Process process, {
103103
bool debugLogging = false,
104104
}) {
105105
final processId = process.pid;
106106
// Use sigint here instead of sigkill. See
107107
// https://github.com/flutter/flutter/issues/117415.
108108
if (debugLogging) {
109-
print('Sending SIGINT to $processId.');
109+
print('${DateTime.now()}: Sending SIGINT to $processId.');
110110
}
111111
Process.killPid(processId, ProcessSignal.sigint);
112112
return process.exitCode;

packages/devtools_test/lib/src/helpers/utils.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Future<Finder> retryUntilFound(
240240
return retryUntilFound(finder, tester: tester, retries: retries - 1);
241241
}
242242

243-
void logStatus(String log) {
243+
void logStatus(String message) {
244244
// ignore: avoid_print, intentional print for test output
245-
print('TEST STATUS: $log');
245+
print('${DateTime.now()}: TEST STATUS: $message');
246246
}

0 commit comments

Comments
 (0)