forked from firka/flutter
Improve logging in the clang-tidy script (flutter/engine#44228)
* Add timestamps to process pool status logs * Log the remaining job names when only a few jobs are pending See https://github.com/flutter/flutter/issues/131689
This commit is contained in:
@@ -89,8 +89,12 @@ class ClangTidy {
|
||||
final StringSink _outSink;
|
||||
final StringSink _errSink;
|
||||
|
||||
late final DateTime _startTime;
|
||||
|
||||
/// Runs clang-tidy on the repo as specified by the [Options].
|
||||
Future<int> run() async {
|
||||
_startTime = DateTime.now();
|
||||
|
||||
if (options.help) {
|
||||
options.printUsage();
|
||||
return 0;
|
||||
@@ -340,8 +344,20 @@ class ClangTidy {
|
||||
|
||||
Future<int> _runJobs(List<WorkerJob> jobs) async {
|
||||
int result = 0;
|
||||
final ProcessPool pool = ProcessPool();
|
||||
final Set<String> pendingJobs = <String>{for (final WorkerJob job in jobs) job.name};
|
||||
|
||||
void reporter(int totalJobs, int completed, int inProgress, int pending, int failed) {
|
||||
return _logWithTimestamp(ProcessPool.defaultReportToString(
|
||||
totalJobs, completed, inProgress, pending, failed));
|
||||
}
|
||||
|
||||
final ProcessPool pool = ProcessPool(printReport: reporter);
|
||||
await for (final WorkerJob job in pool.startWorkers(jobs)) {
|
||||
pendingJobs.remove(job.name);
|
||||
if (pendingJobs.isNotEmpty && pendingJobs.length <= 3) {
|
||||
final List<String> sortedJobs = pendingJobs.toList()..sort();
|
||||
_logWithTimestamp('Still running: $sortedJobs');
|
||||
}
|
||||
if (job.result.exitCode == 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -358,4 +374,10 @@ class ClangTidy {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void _logWithTimestamp(String message) {
|
||||
final Duration elapsedTime = DateTime.now().difference(_startTime);
|
||||
final String seconds = (elapsedTime.inSeconds % 60).toString().padLeft(2, '0');
|
||||
_outSink.writeln('[${elapsedTime.inMinutes}:$seconds] $message');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user