From 6fad914a10b17607c51468df2fbfa8c9640ea0d9 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sat, 20 Aug 2022 21:35:51 -0700 Subject: [PATCH] pre-commit: check generated DBC files (#692) --- .pre-commit-config.yaml | 7 +++++++ generator/test_generator.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cece25e4..5d2d630e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -42,3 +42,10 @@ repos: - --force - --quiet - -j4 +- repo: local + hooks: + - id: generator + name: dbc generator + entry: generator/test_generator.py + language: script + pass_filenames: false diff --git a/generator/test_generator.py b/generator/test_generator.py index dcca4d5b..145bb272 100755 --- a/generator/test_generator.py +++ b/generator/test_generator.py @@ -11,7 +11,11 @@ def test_generator(): ignore = [f for f in os.listdir(opendbc_root) if not f.endswith('_generated.dbc')] comp = filecmp.dircmp(opendbc_root, d, ignore=ignore) - assert len(comp.diff_files) == 0, f"Different files: {comp.diff_files}" + + err = "Generated DBC mismatch\n\n" + err += f"Different files: {comp.diff_files}\n\n" + err += "Run opendbc/generator/generator.py to regenerate DBC files." + assert len(comp.diff_files) == 0, err if __name__ == "__main__":