(clang_format_path: str, fix: bool = False)
| 180 | |
| 181 | |
| 182 | def clang_format(clang_format_path: str, fix: bool = False) -> None: |
| 183 | command = find_command(clang_format_path, msg="clang-format is required") |
| 184 | |
| 185 | version_res = run_pipe(command, '--version').read().strip() |
| 186 | version_re_res = re.search(r'version\s+((?:\w|\.)+)', version_res) |
| 187 | if version_re_res: |
| 188 | version_str = version_re_res.group(1) |
| 189 | else: |
| 190 | raise RuntimeError(f"version not found in `{command} --version`") |
| 191 | |
| 192 | check_version(version_str, CLANG_FORMAT_REQUIRED_VERSION, "clang-format") |
| 193 | |
| 194 | basedir = Path(__file__).parent.absolute() |
| 195 | sources = get_source_files(basedir) |
| 196 | |
| 197 | if fix: |
| 198 | options = ['-i'] |
| 199 | else: |
| 200 | options = ['--dry-run', '--Werror'] |
| 201 | |
| 202 | run(command, *options, *sources, verbose=True, cwd=basedir) |
| 203 | |
| 204 | |
| 205 | def clang_tidy(dir: str, jobs: Optional[int], clang_tidy_path: str, run_clang_tidy_path: str, fix: bool) -> None: |
no test coverage detected