| 46 | |
| 47 | |
| 48 | def check_file(clang_format_binary, style_config_path, filename): |
| 49 | with open(filename, "rb") as f: |
| 50 | actual_source = f.read() |
| 51 | |
| 52 | skip_reason = rules.get_skip_reason(filename, actual_source, skip_links=False) |
| 53 | if skip_reason: |
| 54 | return reporter.LintStatus.SKIPPED, "Style check is omitted: {}".format(skip_reason) |
| 55 | |
| 56 | command = [clang_format_binary, '-assume-filename=' + filename, '-style=file:' + style_config_path] |
| 57 | styled_source = subprocess.check_output(command, input=actual_source) |
| 58 | |
| 59 | if styled_source == actual_source: |
| 60 | return reporter.LintStatus.GOOD, "" |
| 61 | else: |
| 62 | diff = make_diff(actual_source, styled_source) |
| 63 | return reporter.LintStatus.FAIL, diff |
| 64 | |
| 65 | |
| 66 | def make_diff(left, right): |