From 15a6f9e986a7d43921d3e47325405807e7100d96 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 10 Nov 2021 19:10:58 -0800 Subject: [PATCH 1/6] Allow engine variant to be passed into linter script --- ci/lint.sh | 2 +- tools/clang_tidy/README.md | 12 ++++-- tools/clang_tidy/lib/src/options.dart | 45 +++++++++++++++++----- tools/clang_tidy/test/clang_tidy_test.dart | 25 +++++++----- 4 files changed, 62 insertions(+), 22 deletions(-) diff --git a/ci/lint.sh b/ci/lint.sh index eeddd3c7b4ce3..e0b30e9c81dee 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -41,6 +41,6 @@ cd "$SCRIPT_DIR" "$DART" \ --disable-dart-dev \ "$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \ - --compile-commands="$COMPILE_COMMANDS" \ --repo="$SRC_DIR/flutter" \ + --src-dir="$SRC_DIR" \ "$@" diff --git a/tools/clang_tidy/README.md b/tools/clang_tidy/README.md index 2de22f4b56ce9..d2a3bb0f29cdc 100644 --- a/tools/clang_tidy/README.md +++ b/tools/clang_tidy/README.md @@ -1,9 +1,15 @@ # clang_tidy -This is a Dart program/library that runs clang_tidy over modified files. It -takes two mandatory arguments that point at a compile_commands.json command -and the root of the Flutter engine repo: +This is a Dart program/library that runs clang_tidy over modified files in the Flutter engine repo. + +By default the linter runs on the repo files changed contained in `src/out/host_debug/compile_commands.json` command. +To check files other than in `host_debug` use `--target-variant android_debug_unopt`, +`--target-variant ios_debug_sim_unopt`, etc. + +Alternatively, use `--compile-commands` to specify a path to a `compile_commands.json` file. ``` +$ bin/main.dart --target-variant --repo $ bin/main.dart --compile-commands --repo +$ bin/main.dart --help ``` diff --git a/tools/clang_tidy/lib/src/options.dart b/tools/clang_tidy/lib/src/options.dart index 35862849431a0..2671ee1e61a98 100644 --- a/tools/clang_tidy/lib/src/options.dart +++ b/tools/clang_tidy/lib/src/options.dart @@ -5,6 +5,10 @@ import 'dart:io' as io show Directory, File, Platform, stderr; import 'package:args/args.dart'; +import 'package:path/path.dart' as path; + +// Path to root of the flutter/engine repository containing this script. +final String _engineRoot = path.dirname(path.dirname(path.dirname(path.dirname(path.fromUri(io.Platform.script))))); /// A class for organizing the options to the Engine linter, and the files /// that it operates on. @@ -49,12 +53,13 @@ class Options { /// Builds an [Options] instance with an [ArgResults] instance. factory Options._fromArgResults( ArgResults options, { + required io.File buildCommandsPath, StringSink? errSink, }) { return Options( help: options['help'] as bool, verbose: options['verbose'] as bool, - buildCommandsPath: io.File(options['compile-commands'] as String), + buildCommandsPath: buildCommandsPath, repoPath: io.Directory(options['repo'] as String), checksArg: options.wasParsed('checks') ? options['checks'] as String : '', lintAll: io.Platform.environment['FLUTTER_LINT_ALL'] != null || @@ -70,7 +75,17 @@ class Options { StringSink? errSink, }) { final ArgResults argResults = _argParser.parse(arguments); - final String? message = _checkArguments(argResults); + + String? buildCommandsPath = argResults['compile-commands'] as String?; + // path/to/engine/src/out/variant/compile_commands.json + buildCommandsPath ??= path.join( + argResults['src-dir'] as String, + 'out', + argResults['target-variant'] as String, + 'compile_commands.json', + ); + final io.File buildCommands = io.File(buildCommandsPath); + final String? message = _checkArguments(argResults, buildCommands); if (message != null) { return Options._error(message, errSink: errSink); } @@ -79,6 +94,7 @@ class Options { } return Options._fromArgResults( argResults, + buildCommandsPath: buildCommands, errSink: errSink, ); } @@ -86,7 +102,9 @@ class Options { static final ArgParser _argParser = ArgParser() ..addFlag( 'help', + abbr: 'h', help: 'Print help.', + negatable: false, ) ..addFlag( 'lint-all', @@ -112,6 +130,20 @@ class Options { help: 'Use the given path as the source of compile_commands.json. This ' 'file is created by running tools/gn', ) + ..addOption( + 'target-variant', + aliases: ['variant'], + help: 'The engine variant directory containing compile_commands.json ' + 'created by running tools/gn. Ignored if --compile-commands is also passed.', + valueHelp: 'host_debug|android_debug_unopt|ios_debug|ios_debug_sim_unopt', + defaultsTo: 'host_debug', + ) + ..addOption( + 'src-dir', + help: 'Path to the engine src directory. Ignored if --compile-commands is also passed.', + valueHelp: 'path/to/engine/src', + defaultsTo: path.dirname(_engineRoot), + ) ..addOption( 'checks', help: 'Perform the given checks on the code. Defaults to the empty ' @@ -156,26 +188,21 @@ class Options { _errSink.writeln(message); } _errSink.writeln( - 'Usage: bin/main.dart [--help] [--lint-all] [--fix] [--verbose] [--diff-branch]', + 'Usage: bin/main.dart [--help] [--lint-all] [--fix] [--verbose] [--diff-branch] [--target-variant variant] [--src-dir path/to/engine/src]', ); _errSink.writeln(_argParser.usage); } /// Command line argument validation. - static String? _checkArguments(ArgResults argResults) { + static String? _checkArguments(ArgResults argResults, io.File buildCommandsPath) { if (argResults.wasParsed('help')) { return null; } - if (!argResults.wasParsed('compile-commands')) { - return 'ERROR: The --compile-commands argument is required.'; - } - if (!argResults.wasParsed('repo')) { return 'ERROR: The --repo argument is required.'; } - final io.File buildCommandsPath = io.File(argResults['compile-commands'] as String); if (!buildCommandsPath.existsSync()) { return "ERROR: Build commands path ${buildCommandsPath.absolute.path} doesn't exist."; } diff --git a/tools/clang_tidy/test/clang_tidy_test.dart b/tools/clang_tidy/test/clang_tidy_test.dart index cfde20873660f..a57a99d3a0e99 100644 --- a/tools/clang_tidy/test/clang_tidy_test.dart +++ b/tools/clang_tidy/test/clang_tidy_test.dart @@ -12,7 +12,7 @@ import 'package:process_runner/process_runner.dart'; Future main(List args) async { if (args.length < 2) { io.stderr.writeln( - 'Usage: clang_tidy_test.dart [build commands] [repo root]', + 'Usage: clang_tidy_test.dart [path/to/compile_commands.json] [repo root]', ); return 1; } @@ -37,11 +37,14 @@ Future main(List args) async { expect(errBuffer.toString(), contains('Usage: ')); }); - test('Error when --compile-commands is missing', () async { + test('Error when --repo is missing', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy.fromCommandLine( - [], + [ + '--compile-commands', + '/unused', + ], outSink: outBuffer, errSink: errBuffer, ); @@ -51,16 +54,18 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); expect(errBuffer.toString(), contains( - 'ERROR: The --compile-commands argument is required.', + 'ERROR: The --repo argument is required.', )); }); - test('Error when --repo is missing', () async { + test('Error when --compile-commands path does not exist', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy.fromCommandLine( [ '--compile-commands', + '/does/not/exist', + '--repo', '/unused', ], outSink: outBuffer, @@ -72,17 +77,19 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); expect(errBuffer.toString(), contains( - 'ERROR: The --repo argument is required.', + "ERROR: Build commands path /does/not/exist doesn't exist.", )); }); - test('Error when --compile-commands path does not exist', () async { + test('Error when --src-dir path does not exist, uses target variant in path', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy.fromCommandLine( [ - '--compile-commands', + '--src-dir', '/does/not/exist', + '--target-variant', + 'ios_debug_unopt', '--repo', '/unused', ], @@ -95,7 +102,7 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); expect(errBuffer.toString(), contains( - "ERROR: Build commands path /does/not/exist doesn't exist.", + "ERROR: Build commands path /does/not/exist/out/ios_debug_unopt/compile_commands.json doesn't exist.", )); }); From 78845fda80c498569028af8b63b638da62115772 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 10 Nov 2021 22:25:31 -0800 Subject: [PATCH 2/6] check options --- tools/clang_tidy/lib/src/options.dart | 11 ++++- tools/clang_tidy/test/clang_tidy_test.dart | 52 +++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/tools/clang_tidy/lib/src/options.dart b/tools/clang_tidy/lib/src/options.dart index 2671ee1e61a98..49bcb273fbcda 100644 --- a/tools/clang_tidy/lib/src/options.dart +++ b/tools/clang_tidy/lib/src/options.dart @@ -199,8 +199,17 @@ class Options { return null; } + final bool compileCommandsParsed = argResults.wasParsed('compile-commands'); + if (compileCommandsParsed && argResults.wasParsed('target-variant')) { + return 'ERROR: --compile-commands option cannot be used with --target-variant.'; + } + + if (compileCommandsParsed && argResults.wasParsed('src-dir')) { + return 'ERROR: --compile-commands option cannot be used with --src-dir.'; + } + if (!argResults.wasParsed('repo')) { - return 'ERROR: The --repo argument is required.'; + return 'ERROR: The --repo option is required.'; } if (!buildCommandsPath.existsSync()) { diff --git a/tools/clang_tidy/test/clang_tidy_test.dart b/tools/clang_tidy/test/clang_tidy_test.dart index a57a99d3a0e99..3c282b44d946d 100644 --- a/tools/clang_tidy/test/clang_tidy_test.dart +++ b/tools/clang_tidy/test/clang_tidy_test.dart @@ -37,6 +37,56 @@ Future main(List args) async { expect(errBuffer.toString(), contains('Usage: ')); }); + test('Error when --compile-commands and --target-variant are used together', () async { + final StringBuffer outBuffer = StringBuffer(); + final StringBuffer errBuffer = StringBuffer(); + final ClangTidy clangTidy = ClangTidy.fromCommandLine( + [ + '--repo', + '/unused', + '--compile-commands', + '/unused', + '--target-variant', + 'unused' + ], + outSink: outBuffer, + errSink: errBuffer, + ); + + final int result = await clangTidy.run(); + + expect(clangTidy.options.help, isFalse); + expect(result, equals(1)); + expect(errBuffer.toString(), contains( + 'ERROR: --compile-commands option cannot be used with --target-variant.', + )); + }); + + test('Error when --compile-commands and --src-dir are used together', () async { + final StringBuffer outBuffer = StringBuffer(); + final StringBuffer errBuffer = StringBuffer(); + final ClangTidy clangTidy = ClangTidy.fromCommandLine( + [ + '--repo', + '/unused', + '--compile-commands', + '/unused', + '--src-dir', + '/unused', + ], + outSink: outBuffer, + errSink: errBuffer, + ); + + final int result = await clangTidy.run(); + + expect(clangTidy.options.help, isFalse); + expect(result, equals(1)); + expect(errBuffer.toString(), contains( + 'ERROR: --compile-commands option cannot be used with --src-dir.', + )); + }); + test('Error when --repo is missing', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); @@ -54,7 +104,7 @@ Future main(List args) async { expect(clangTidy.options.help, isFalse); expect(result, equals(1)); expect(errBuffer.toString(), contains( - 'ERROR: The --repo argument is required.', + 'ERROR: The --repo option is required.', )); }); From 1bb142431799f9bcc9c82c5b552459e97dca63e8 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 10 Nov 2021 22:41:23 -0800 Subject: [PATCH 3/6] Fix help message --- tools/clang_tidy/lib/src/options.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/clang_tidy/lib/src/options.dart b/tools/clang_tidy/lib/src/options.dart index 49bcb273fbcda..f4970579273e7 100644 --- a/tools/clang_tidy/lib/src/options.dart +++ b/tools/clang_tidy/lib/src/options.dart @@ -128,19 +128,20 @@ class Options { ..addOption( 'compile-commands', help: 'Use the given path as the source of compile_commands.json. This ' - 'file is created by running tools/gn', + 'file is created by running "tools/gn". Cannot be used with --target-variant ' + 'or --src-dir.', ) ..addOption( 'target-variant', aliases: ['variant'], help: 'The engine variant directory containing compile_commands.json ' - 'created by running tools/gn. Ignored if --compile-commands is also passed.', + 'created by running "tools/gn". Cannot be used with --compile-commands.', valueHelp: 'host_debug|android_debug_unopt|ios_debug|ios_debug_sim_unopt', defaultsTo: 'host_debug', ) ..addOption( 'src-dir', - help: 'Path to the engine src directory. Ignored if --compile-commands is also passed.', + help: 'Path to the engine src directory. Cannot be used with --compile-commands.', valueHelp: 'path/to/engine/src', defaultsTo: path.dirname(_engineRoot), ) From b04ab6bc6606b0df8092333b85c9d8e2b2ce36d1 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 11 Nov 2021 00:24:23 -0800 Subject: [PATCH 4/6] Show all lint failures, not just the first --- tools/clang_tidy/lib/clang_tidy.dart | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/tools/clang_tidy/lib/clang_tidy.dart b/tools/clang_tidy/lib/clang_tidy.dart index 1c9a517733ee5..efd044b2f4f2f 100644 --- a/tools/clang_tidy/lib/clang_tidy.dart +++ b/tools/clang_tidy/lib/clang_tidy.dart @@ -229,16 +229,8 @@ class ClangTidy { if (job.result.exitCode == 0) { continue; } - if (job.exception != null) { - _errSink.writeln( - '\nā— A clang-tidy job failed to run, aborting:\n${job.exception}', - ); - result = 1; - break; - } else { - _errSink.writeln('āŒ Failures for ${job.name}:'); - _errSink.writeln(job.result.stdout); - } + _errSink.writeln('āŒ Failures for ${job.name}:'); + _errSink.writeln(job.result.stdout); result = 1; } return result; From 6e333897af3bd07ed705cac41045c0426e21357d Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 11 Nov 2021 00:39:42 -0800 Subject: [PATCH 5/6] Use .clang-format when fixing files --- tools/clang_tidy/lib/src/command.dart | 4 +++- tools/clang_tidy/test/clang_tidy_test.dart | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/clang_tidy/lib/src/command.dart b/tools/clang_tidy/lib/src/command.dart index 7a1d6df8fc234..1bc87d07be766 100644 --- a/tools/clang_tidy/lib/src/command.dart +++ b/tools/clang_tidy/lib/src/command.dart @@ -134,8 +134,10 @@ class Command { filePath, if (checks != null) checks, - if (fix) + if (fix) ...[ '--fix', + '--format-style=file', + ], '--', ]; args.addAll(tidyArgs.split(' ')); diff --git a/tools/clang_tidy/test/clang_tidy_test.dart b/tools/clang_tidy/test/clang_tidy_test.dart index 3c282b44d946d..d14ac16bf4f1c 100644 --- a/tools/clang_tidy/test/clang_tidy_test.dart +++ b/tools/clang_tidy/test/clang_tidy_test.dart @@ -275,6 +275,7 @@ Future main(List args) async { '../../buildtools/mac-x64/clang/bin/clang-tidy', filePath, '--fix', + '--format-style=file', '--', '', filePath, From 23d6a03e9dfb9129d5dfabfdde6160f0ca6166f4 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Thu, 11 Nov 2021 10:43:24 -0800 Subject: [PATCH 6/6] Remove --repo --- ci/lint.sh | 1 - tools/clang_tidy/README.md | 4 +- tools/clang_tidy/bin/main.dart | 4 +- tools/clang_tidy/lib/clang_tidy.dart | 2 - tools/clang_tidy/lib/src/options.dart | 19 +----- tools/clang_tidy/test/clang_tidy_test.dart | 64 +------------------- tools/githooks/lib/src/pre_push_command.dart | 1 - 7 files changed, 8 insertions(+), 87 deletions(-) diff --git a/ci/lint.sh b/ci/lint.sh index e0b30e9c81dee..6355e637fd1e1 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -41,6 +41,5 @@ cd "$SCRIPT_DIR" "$DART" \ --disable-dart-dev \ "$SRC_DIR/flutter/tools/clang_tidy/bin/main.dart" \ - --repo="$SRC_DIR/flutter" \ --src-dir="$SRC_DIR" \ "$@" diff --git a/tools/clang_tidy/README.md b/tools/clang_tidy/README.md index d2a3bb0f29cdc..460ecbbfb7959 100644 --- a/tools/clang_tidy/README.md +++ b/tools/clang_tidy/README.md @@ -9,7 +9,7 @@ To check files other than in `host_debug` use `--target-variant android_debug_un Alternatively, use `--compile-commands` to specify a path to a `compile_commands.json` file. ``` -$ bin/main.dart --target-variant --repo -$ bin/main.dart --compile-commands --repo +$ bin/main.dart --target-variant +$ bin/main.dart --compile-commands $ bin/main.dart --help ``` diff --git a/tools/clang_tidy/bin/main.dart b/tools/clang_tidy/bin/main.dart index 405381e4a3d5c..4e3bd27ec9f6e 100644 --- a/tools/clang_tidy/bin/main.dart +++ b/tools/clang_tidy/bin/main.dart @@ -7,8 +7,8 @@ // Runs clang-tidy on files with changes. // // Basic Usage: -// dart bin/main.dart --compile-commands \ -// --repo \ +// dart bin/main.dart --compile-commands +// dart bin/main.dart --target-variant // // User environment variable FLUTTER_LINT_ALL to run on all files. diff --git a/tools/clang_tidy/lib/clang_tidy.dart b/tools/clang_tidy/lib/clang_tidy.dart index efd044b2f4f2f..77650d226d599 100644 --- a/tools/clang_tidy/lib/clang_tidy.dart +++ b/tools/clang_tidy/lib/clang_tidy.dart @@ -45,7 +45,6 @@ class ClangTidy { /// will otherwise go to stderr. ClangTidy({ required io.File buildCommandsPath, - required io.Directory repoPath, String checksArg = '', bool lintAll = false, bool fix = false, @@ -54,7 +53,6 @@ class ClangTidy { }) : options = Options( buildCommandsPath: buildCommandsPath, - repoPath: repoPath, checksArg: checksArg, lintAll: lintAll, fix: fix, diff --git a/tools/clang_tidy/lib/src/options.dart b/tools/clang_tidy/lib/src/options.dart index f4970579273e7..264fa37bdb6ff 100644 --- a/tools/clang_tidy/lib/src/options.dart +++ b/tools/clang_tidy/lib/src/options.dart @@ -16,7 +16,6 @@ class Options { /// Builds an instance of [Options] from the arguments. Options({ required this.buildCommandsPath, - required this.repoPath, this.help = false, this.verbose = false, this.checksArg = '', @@ -34,7 +33,6 @@ class Options { return Options( errorMessage: message, buildCommandsPath: io.File('none'), - repoPath: io.Directory('none'), errSink: errSink, ); } @@ -45,7 +43,6 @@ class Options { return Options( help: true, buildCommandsPath: io.File('none'), - repoPath: io.Directory('none'), errSink: errSink, ); } @@ -60,7 +57,6 @@ class Options { help: options['help'] as bool, verbose: options['verbose'] as bool, buildCommandsPath: buildCommandsPath, - repoPath: io.Directory(options['repo'] as String), checksArg: options.wasParsed('checks') ? options['checks'] as String : '', lintAll: io.Platform.environment['FLUTTER_LINT_ALL'] != null || options['lint-all'] as bool, @@ -121,10 +117,6 @@ class Options { help: 'Print verbose output.', defaultsTo: false, ) - ..addOption( - 'repo', - help: 'Use the given path as the repo path', - ) ..addOption( 'compile-commands', help: 'Use the given path as the source of compile_commands.json. This ' @@ -162,7 +154,7 @@ class Options { final io.File buildCommandsPath; /// The root of the flutter/engine repository. - final io.Directory repoPath; + final io.Directory repoPath = io.Directory(_engineRoot); /// Arguments to plumb through to clang-tidy formatted as a command line /// argument. @@ -209,19 +201,10 @@ class Options { return 'ERROR: --compile-commands option cannot be used with --src-dir.'; } - if (!argResults.wasParsed('repo')) { - return 'ERROR: The --repo option is required.'; - } - if (!buildCommandsPath.existsSync()) { return "ERROR: Build commands path ${buildCommandsPath.absolute.path} doesn't exist."; } - final io.Directory repoPath = io.Directory(argResults['repo'] as String); - if (!repoPath.existsSync()) { - return "ERROR: Repo path ${repoPath.absolute.path} doesn't exist."; - } - return null; } } diff --git a/tools/clang_tidy/test/clang_tidy_test.dart b/tools/clang_tidy/test/clang_tidy_test.dart index d14ac16bf4f1c..76e0e7c775f13 100644 --- a/tools/clang_tidy/test/clang_tidy_test.dart +++ b/tools/clang_tidy/test/clang_tidy_test.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:io' as io show Directory, File, Platform, stderr; +import 'dart:io' as io show File, Platform, stderr; import 'package:clang_tidy/clang_tidy.dart'; import 'package:clang_tidy/src/command.dart'; @@ -10,14 +10,13 @@ import 'package:litetest/litetest.dart'; import 'package:process_runner/process_runner.dart'; Future main(List args) async { - if (args.length < 2) { + if (args.isEmpty) { io.stderr.writeln( - 'Usage: clang_tidy_test.dart [path/to/compile_commands.json] [repo root]', + 'Usage: clang_tidy_test.dart [path/to/compile_commands.json]', ); return 1; } final String buildCommands = args[0]; - final String repoRoot = args[1]; test('--help gives help', () async { final StringBuffer outBuffer = StringBuffer(); @@ -42,8 +41,6 @@ Future main(List args) async { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy.fromCommandLine( [ - '--repo', - '/unused', '--compile-commands', '/unused', '--target-variant', @@ -67,8 +64,6 @@ Future main(List args) async { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy.fromCommandLine( [ - '--repo', - '/unused', '--compile-commands', '/unused', '--src-dir', @@ -87,27 +82,6 @@ Future main(List args) async { )); }); - test('Error when --repo is missing', () async { - final StringBuffer outBuffer = StringBuffer(); - final StringBuffer errBuffer = StringBuffer(); - final ClangTidy clangTidy = ClangTidy.fromCommandLine( - [ - '--compile-commands', - '/unused', - ], - outSink: outBuffer, - errSink: errBuffer, - ); - - final int result = await clangTidy.run(); - - expect(clangTidy.options.help, isFalse); - expect(result, equals(1)); - expect(errBuffer.toString(), contains( - 'ERROR: The --repo option is required.', - )); - }); - test('Error when --compile-commands path does not exist', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); @@ -115,8 +89,6 @@ Future main(List args) async { [ '--compile-commands', '/does/not/exist', - '--repo', - '/unused', ], outSink: outBuffer, errSink: errBuffer, @@ -140,8 +112,6 @@ Future main(List args) async { '/does/not/exist', '--target-variant', 'ios_debug_unopt', - '--repo', - '/unused', ], outSink: outBuffer, errSink: errBuffer, @@ -156,36 +126,11 @@ Future main(List args) async { )); }); - test('Error when --repo path does not exist', () async { - final StringBuffer outBuffer = StringBuffer(); - final StringBuffer errBuffer = StringBuffer(); - final ClangTidy clangTidy = ClangTidy.fromCommandLine( - [ - '--compile-commands', - // This file needs to exist, and be UTF8 line-parsable. - io.Platform.script.path, - '--repo', - '/does/not/exist', - ], - outSink: outBuffer, - errSink: errBuffer, - ); - - final int result = await clangTidy.run(); - - expect(clangTidy.options.help, isFalse); - expect(result, equals(1)); - expect(errBuffer.toString(), contains( - "ERROR: Repo path /does/not/exist doesn't exist.", - )); - }); - test('lintAll=true checks all files', () async { final StringBuffer outBuffer = StringBuffer(); final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy( buildCommandsPath: io.File(buildCommands), - repoPath: io.Directory(repoRoot), lintAll: true, outSink: outBuffer, errSink: errBuffer, @@ -199,7 +144,6 @@ Future main(List args) async { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy( buildCommandsPath: io.File(buildCommands), - repoPath: io.Directory(repoRoot), outSink: outBuffer, errSink: errBuffer, ); @@ -212,7 +156,6 @@ Future main(List args) async { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy( buildCommandsPath: io.File(buildCommands), - repoPath: io.Directory(repoRoot), lintAll: true, outSink: outBuffer, errSink: errBuffer, @@ -238,7 +181,6 @@ Future main(List args) async { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy( buildCommandsPath: io.File(buildCommands), - repoPath: io.Directory(repoRoot), lintAll: true, outSink: outBuffer, errSink: errBuffer, diff --git a/tools/githooks/lib/src/pre_push_command.dart b/tools/githooks/lib/src/pre_push_command.dart index 428c10e8307be..e1e36999f7eb0 100644 --- a/tools/githooks/lib/src/pre_push_command.dart +++ b/tools/githooks/lib/src/pre_push_command.dart @@ -60,7 +60,6 @@ class PrePushCommand extends Command { final StringBuffer errBuffer = StringBuffer(); final ClangTidy clangTidy = ClangTidy( buildCommandsPath: compileCommands, - repoPath: io.Directory(flutterRoot), outSink: outBuffer, errSink: errBuffer, );