Apache DataFusion SQL Query Engine
ARROW-7990: [Developer][C++] Add option to run "archery lint --iwyu" on all C++ files, not just the ones that you changed. Add "match" option to iwyu.sh
Wes McKinneyb56a0eb11fc1
diff --git a/dev/archery/archery/cli.py b/dev/archery/archery/cli.pyindex 4d31764640..1f34e1de78 100644--- a/dev/archery/archery/cli.py+++ b/dev/archery/archery/cli.py@@ -210,7 +210,7 @@ lint_checks = [LintCheck('clang-format', "Format C++ files with clang-format."),LintCheck('clang-tidy', "Lint C++ files with clang-tidy."),LintCheck('cpplint', "Lint C++ files with cpplint."),- LintCheck('iwyu', "Lint C++ files with Include-What-You-Use."),+ LintCheck('iwyu', "Lint changed C++ files with Include-What-You-Use."),LintCheck('flake8', "Lint Python files with flake8."),LintCheck('numpydoc', "Lint Python files with numpydoc."),LintCheck('cmake-format', "Format CMake files with cmake-format.py."),@@ -239,11 +239,13 @@ def decorate_lint_command(cmd):help="Specify Arrow source directory")@click.option("--fix", is_flag=True, type=BOOL, default=False,help="Toggle fixing the lint errors if the linter supports it.")[email protected]("--iwyu_all", is_flag=True, type=BOOL, default=False,+ help="Run IWYU on all C++ files if enabled")@click.option("-a", "--all", is_flag=True, default=False,help="Enable all checks.")@decorate_lint_command@click.pass_context-def lint(ctx, src, fix, **checks):+def lint(ctx, src, fix, iwyu_all, **checks):if checks.pop('all'):# "--all" is given => enable all non-selected checksfor k, v in checks.items():@@ -253,7 +255,7 @@ def lint(ctx, src, fix, **checks):raise click.UsageError("Need to enable at least one lint check (try --help)")try:- linter(src, fix, **checks)+ linter(src, fix, iwyu_all=iwyu_all, **checks)except LintValidationException:sys.exit(1)diff --git a/dev/archery/archery/utils/lint.py b/dev/archery/archery/utils/lint.pyindex fe417f21a7..4c84f5a443 100644--- a/dev/archery/archery/utils/lint.py+++ b/dev/archery/archery/utils/lint.py@@ -49,7 +49,8 @@ class LintResult:def cpp_linter(src, build_dir, clang_format=True, cpplint=True,- clang_tidy=False, iwyu=False, fix=False):+ clang_tidy=False, iwyu=False, iwyu_all=False,+ fix=False):""" Run clang-format, cpplint and clang-tidy on cpp/ codebase. """logger.info("Running C++ linters")@@ -81,7 +82,11 @@ def cpp_linter(src, build_dir, clang_format=True, cpplint=True,yield LintResult.from_cmd(build.run("check-clang-tidy", check=False))if iwyu:- yield LintResult.from_cmd(build.run("iwyu", check=False))+ if iwyu_all:+ iwyu_cmd = "iwyu-all"+ else:+ iwyu_cmd = "iwyu"+ yield LintResult.from_cmd(build.run(iwyu_cmd, check=False))class CMakeFormat(Command):@@ -284,8 +289,9 @@ def docker_linter(src):def linter(src, fix=False, *, clang_format=False, cpplint=False,- clang_tidy=False, iwyu=False, flake8=False, numpydoc=False,- cmake_format=False, rat=False, r=False, rust=False, docker=False):+ clang_tidy=False, iwyu=False, iwyu_all=False,+ flake8=False, numpydoc=False, cmake_format=False, rat=False,+ r=False, rust=False, docker=False):"""Run all linters."""with tmpdir(prefix="arrow-lint-") as root:build_dir = os.path.join(root, "cpp-build")@@ -301,6 +307,7 @@ def linter(src, fix=False, *, clang_format=False, cpplint=False,cpplint=cpplint,clang_tidy=clang_tidy,iwyu=iwyu,+ iwyu_all=iwyu_all,fix=fix))if flake8: