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:
2
DEPS
2
DEPS
@@ -664,7 +664,7 @@ deps = {
|
||||
Var('github_git') + '/google/process.dart.git' + '@' + '0c9aeac86dcc4e3a6cf760b76fed507107e244d5', # 4.2.1
|
||||
|
||||
'src/third_party/pkg/process_runner':
|
||||
Var('github_git') + '/google/process_runner.git' + '@' + 'd632ea0bfd814d779fcc53a361ed33eaf3620a0b', # 4.0.1
|
||||
Var('github_git') + '/google/process_runner.git' + '@' + 'f24c69efdcaf109168f23d381fa281453d2bc9b1', # 4.1.2
|
||||
|
||||
'src/third_party/pkg/quiver':
|
||||
Var('github_git') + '/google/quiver-dart.git' + '@' + '90b92bee895e507d435012356a8b5c5f17eafa52', # 3.2.1
|
||||
|
||||
@@ -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