Skip to content

Commit 6b29ddc

Browse files
committed
feat(configuration_steps): Only check files managed by git
1 parent 3d35038 commit 6b29ddc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/test_configuration_steps_schema.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
SPDX-License-Identifier: GPL-3.0-or-later
1414
"""
1515

16+
import fnmatch
1617
import json
1718
import os
19+
import subprocess
1820

1921
import pytest
2022
from jsonschema import ValidationError, exceptions, validate, validators
@@ -51,7 +53,21 @@ def find_json_files(directory) -> list[str]:
5153
return json_files
5254

5355

54-
@pytest.mark.parametrize("json_file", find_json_files("."))
56+
def git_tracked_json_files() -> list[str]:
57+
"""Find all git tracked configuration_steps_*.json files in the repository."""
58+
try:
59+
files = subprocess.check_output(["git", "ls-files"], encoding="utf-8").splitlines() # noqa: S607
60+
return [
61+
f
62+
for f in files
63+
if fnmatch.fnmatch(os.path.basename(f), "configuration_steps_*.json")
64+
and os.path.basename(f) != "configuration_steps_schema.json"
65+
]
66+
except (subprocess.CalledProcessError, FileNotFoundError):
67+
return find_json_files(".")
68+
69+
70+
@pytest.mark.parametrize("json_file", git_tracked_json_files())
5571
def test_json_schema(json_file) -> None:
5672
"""Test that the JSON files conform to the predefined schema."""
5773
with open(json_file, encoding="utf-8") as file:

0 commit comments

Comments
 (0)