Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 34d3196

Browse files
committed
Improve logging in the clang-tidy script
* Add timestamps to process pool status logs * Log the remaining job names when only a few jobs are pending See flutter/flutter#131689
1 parent 42c8bb8 commit 34d3196

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

DEPS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ deps = {
664664
Var('github_git') + '/google/process.dart.git' + '@' + '0c9aeac86dcc4e3a6cf760b76fed507107e244d5', # 4.2.1
665665

666666
'src/third_party/pkg/process_runner':
667-
Var('github_git') + '/google/process_runner.git' + '@' + 'd632ea0bfd814d779fcc53a361ed33eaf3620a0b', # 4.0.1
667+
Var('github_git') + '/google/process_runner.git' + '@' + 'f24c69efdcaf109168f23d381fa281453d2bc9b1', # 4.1.2
668668

669669
'src/third_party/pkg/quiver':
670670
Var('github_git') + '/google/quiver-dart.git' + '@' + '90b92bee895e507d435012356a8b5c5f17eafa52', # 3.2.1

tools/clang_tidy/lib/clang_tidy.dart

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,12 @@ class ClangTidy {
8989
final StringSink _outSink;
9090
final StringSink _errSink;
9191

92+
late final DateTime _startTime;
93+
9294
/// Runs clang-tidy on the repo as specified by the [Options].
9395
Future<int> run() async {
96+
_startTime = DateTime.now();
97+
9498
if (options.help) {
9599
options.printUsage();
96100
return 0;
@@ -340,8 +344,20 @@ class ClangTidy {
340344

341345
Future<int> _runJobs(List<WorkerJob> jobs) async {
342346
int result = 0;
343-
final ProcessPool pool = ProcessPool();
347+
final Set<String> pendingJobs = <String>{for (final WorkerJob job in jobs) job.name};
348+
349+
void reporter(int totalJobs, int completed, int inProgress, int pending, int failed) {
350+
return _logWithTimestamp(ProcessPool.defaultReportToString(
351+
totalJobs, completed, inProgress, pending, failed));
352+
}
353+
354+
final ProcessPool pool = ProcessPool(printReport: reporter);
344355
await for (final WorkerJob job in pool.startWorkers(jobs)) {
356+
pendingJobs.remove(job.name);
357+
if (pendingJobs.isNotEmpty && pendingJobs.length <= 3) {
358+
final List<String> sortedJobs = pendingJobs.toList()..sort();
359+
_logWithTimestamp('Still running: $sortedJobs');
360+
}
345361
if (job.result.exitCode == 0) {
346362
continue;
347363
}
@@ -358,4 +374,10 @@ class ClangTidy {
358374
}
359375
return result;
360376
}
377+
378+
void _logWithTimestamp(String message) {
379+
final Duration elapsedTime = DateTime.now().difference(_startTime);
380+
final String seconds = (elapsedTime.inSeconds % 60).toString().padLeft(2, '0');
381+
_outSink.writeln('[${elapsedTime.inMinutes}:$seconds] $message');
382+
}
361383
}

0 commit comments

Comments
 (0)