From 7cf6640caaa8117fec5dd798372dcbe52be5a1cd Mon Sep 17 00:00:00 2001 From: Michael Osthege Date: Sun, 20 Jun 2021 13:35:16 +0200 Subject: [PATCH] Analyze included/excluded test files based on YAML job matrix Compared to the previous regex-based approach, this can distinguish by OS and floatX setting, allowing for more informative outputs. --- .pre-commit-config.yaml | 1 + scripts/check_all_tests_are_covered.py | 101 +++++++++++++++++++------ 2 files changed, 79 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4739980765..cef12c6d4b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,6 +36,7 @@ repos: - repo: local hooks: - id: check-no-tests-are-ignored + additional_dependencies: [pandas,pyyaml] entry: python scripts/check_all_tests_are_covered.py files: ^\.github/workflows/pytest\.yml$ language: python diff --git a/scripts/check_all_tests_are_covered.py b/scripts/check_all_tests_are_covered.py index 4076ef552a..0f38437ec0 100644 --- a/scripts/check_all_tests_are_covered.py +++ b/scripts/check_all_tests_are_covered.py @@ -6,38 +6,93 @@ This is intended to be used as a pre-commit hook, see `.pre-commit-config.yaml`. You can run it manually with `pre-commit run check-no-tests-are-ignored --all`. """ +import itertools import logging -import re +import os from pathlib import Path +import pandas +import yaml + _log = logging.getLogger(__file__) +logging.basicConfig(level=logging.DEBUG) -if __name__ == "__main__": - testing_workflows = ["jaxtests.yml", "pytest.yml"] - ignored = set() - non_ignored = set() - for wfyml in testing_workflows: - pytest_ci_job = Path(".github") / "workflows" / wfyml - txt = pytest_ci_job.read_text() - ignored = set(re.findall(r"(?<=--ignore=)(pymc3/tests.*\.py)", txt)) - non_ignored = non_ignored.union(set(re.findall(r"(?