From d16cb01daf3f4e4b4fbf4be2b4405c615a670121 Mon Sep 17 00:00:00 2001 From: Erwan Rouchet <rouchet@teklia.com> Date: Fri, 13 Sep 2024 10:59:55 +0000 Subject: [PATCH] Add a pre-commit hook for long test files --- .pre-commit-config.yaml | 10 ++++++++++ ci/long-test-files.sh | 2 ++ 2 files changed, 12 insertions(+) create mode 100755 ci/long-test-files.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dab142c89c..c483214c1d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,3 +34,13 @@ repos: - repo: meta hooks: - id: check-useless-excludes + - repo: local + hooks: + - id: long-test-files + name: Warn about long unit test files + language: script + entry: ci/long-test-files.sh + # Only run on Arkindex unit test files + files: '^arkindex\/[^\/]*\/tests\/(.*\/)?test_.*\.py' + # Always show output, even when the hook passes, since the hook only warns and doesn't fail + verbose: true diff --git a/ci/long-test-files.sh b/ci/long-test-files.sh new file mode 100755 index 0000000000..0eac44393b --- /dev/null +++ b/ci/long-test-files.sh @@ -0,0 +1,2 @@ +#!/bin/sh +wc -l "$@" | awk '$2 != "total" && $1 > 1000 { OFS=""; print $2, " is too long (", $1, " lines)" }' -- GitLab