- fail closed on MCP input and compile database policy - add shared scan catalogs, finding queries, and tiered gates
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Select regression tests from reviewed changed-path impact rules."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import importlib
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
DEFAULT_MANIFEST = ROOT / "tests" / "quality" / "impacted_tests.json"
|
|
|
|
|
|
def select_tests(changed_paths: list[str], manifest: Path) -> dict[str, object]:
|
|
module = importlib.import_module("benchmarks.fold_eval.test_selection")
|
|
selector = module.select_tests
|
|
result = selector(changed_paths, manifest)
|
|
if not isinstance(result, dict):
|
|
raise ValueError("test selector returned a non-object result")
|
|
return result
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("paths", nargs="*")
|
|
parser.add_argument("--manifest", type=Path, default=DEFAULT_MANIFEST)
|
|
parser.add_argument("--output", type=Path)
|
|
args = parser.parse_args()
|
|
try:
|
|
selection = select_tests(args.paths, args.manifest)
|
|
except ValueError as error:
|
|
print(error, file=sys.stderr)
|
|
return 2
|
|
payload = json.dumps(selection, indent=2, sort_keys=True) + "\n"
|
|
if args.output is not None:
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
args.output.write_text(payload, encoding="utf-8")
|
|
print(payload, end="")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|