Skip to content

Commit

Permalink
Upgrade to latest process runner, fix commands that throw to fail test (
Browse files Browse the repository at this point in the history
flutter#21827)

This fixes the lint script to fail when the clang-tidy command itself fails to execute, and print the exception that was raised.
  • Loading branch information
gspencergoog committed Oct 14, 2020
1 parent df57e21 commit ce75dda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 10 additions & 6 deletions ci/bin/lint.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import 'dart:async' show Completer;
import 'dart:convert' show jsonDecode, utf8, LineSplitter;
import 'dart:io' show File, exit, Directory, FileSystemEntity, Platform, stderr;
import 'dart:io' show File, exit, Directory, FileSystemEntity, Platform, stderr, exitCode;

import 'package:args/args.dart';
import 'package:path/path.dart' as path;
Expand Down Expand Up @@ -223,7 +223,6 @@ void main(List<String> arguments) async {
'commands associated with them and can be lint checked.');
}

int exitCode = 0;
final List<WorkerJob> jobs = <WorkerJob>[];
for (Command command in changedFileBuildCommands) {
final String relativePath = path.relative(command.file.path, from: repoPath.parent.path);
Expand All @@ -245,16 +244,21 @@ void main(List<String> arguments) async {
final ProcessPool pool = ProcessPool();

await for (final WorkerJob job in pool.startWorkers(jobs)) {
if (job.result?.stdout.isEmpty ?? true) {
if (job.result?.exitCode == 0) {
continue;
}
print('❌ Failures for ${job.name}:');
print(job.result.stdout);
if (job.result == null) {
print('\n❗ A clang-tidy job failed to run, aborting:\n${job.exception}');
exitCode = 1;
break;
} else {
print('❌ Failures for ${job.name}:');
print(job.result.stdout);
}
exitCode = 1;
}
print('\n');
if (exitCode == 0) {
print('No lint problems found.');
}
exit(exitCode);
}
2 changes: 1 addition & 1 deletion ci/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
args: ^1.6.0
path: ^1.7.0
isolate: ^2.0.3
process_runner: ^3.0.0
process_runner: ^3.1.0

environment:
sdk: '>=2.8.0 <3.0.0'

0 comments on commit ce75dda

Please sign in to comment.