Files
cleveragents-core/robot/helper_semantic_validation_suite.py
T
CoreRasurae 7e6f6fae37
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 12s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 17s
CI / typecheck (pull_request) Successful in 31s
CI / security (pull_request) Successful in 31s
CI / unit_tests (pull_request) Successful in 1m46s
CI / docker (pull_request) Successful in 38s
CI / integration_tests (pull_request) Successful in 2m52s
CI / coverage (pull_request) Successful in 3m41s
CI / benchmark-regression (pull_request) Successful in 23m24s
CI / lint (push) Successful in 14s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 17s
CI / typecheck (push) Successful in 33s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 35s
CI / unit_tests (push) Successful in 2m13s
CI / docker (push) Successful in 38s
CI / integration_tests (push) Successful in 2m58s
CI / coverage (push) Successful in 3m44s
CI / benchmark-publish (push) Successful in 13m19s
test(validation): add semantic validation suites
Add comprehensive semantic validation test suites covering five
new fixture categories: language porting mismatches, dependency
graph violations, API surface changes, cross-file symbols, and
circular import detection.

New BDD scenarios (38) exercise all six built-in rules against
fixture-driven inputs.  Robot Framework integration tests (11)
validate end-to-end rule execution via the SemanticValidationService.
ASV benchmarks (6 suites) establish performance baselines for
batch validation throughput and per-rule latency.

Files added:
- features/fixtures/validation/{language_porting_mismatches,
  dependency_graph_violations, api_surface_changes,
  cross_file_symbols, circular_import_detection}.json
- features/semantic_validation_suite.feature
- features/steps/semantic_validation_suite_steps.py
- robot/semantic_validation_suite.robot
- robot/helper_semantic_validation_suite.py
- benchmarks/semantic_validation_suite_bench.py
- docs/reference/semantic_validation_coverage.md

All 11 nox sessions pass (lint, format, typecheck, security_scan,
dead_code, unit_tests, integration_tests, docs, build, benchmark,
coverage_report).  Coverage remains at 97%.

ISSUES CLOSED: #316
2026-03-02 22:05:53 +00:00

169 lines
5.1 KiB
Python

"""Helper script for Robot Framework semantic validation suite tests.
Self-contained Python helper that loads and validates semantic validation
fixture suites (porting mismatches, dependency violations, API surface
changes, cross-file symbols, duplicate relative imports). Prints
sentinel strings on success and exits with code 1 on failure.
Uses :mod:`features.fixtures.validation.suite_helpers` for shared
loading, lookup, and verification logic.
"""
from __future__ import annotations
import sys
from collections.abc import Callable
from pathlib import Path
# Ensure src and fixture helpers are importable when run from workspace root
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
_FIXTURES_DIR = str(
Path(__file__).resolve().parents[1] / "features" / "fixtures" / "validation"
)
if _FIXTURES_DIR not in sys.path:
sys.path.insert(0, _FIXTURES_DIR)
from suite_helpers import ( # noqa: E402, I001
API_FILENAME,
CIRCULAR_FILENAME,
CROSS_FILE_FILENAME,
DEPENDENCY_FILENAME,
PORTING_FILENAME,
load_fixtures,
run_fixture,
validate_fixture_schema,
verify_fixture_result,
)
# ---------------------------------------------------------------------------
# Sub-commands
# ---------------------------------------------------------------------------
def test_porting_fixtures() -> None:
"""Load and verify all porting fixtures."""
fixtures = load_fixtures(PORTING_FILENAME)
assert len(fixtures) >= 6
for f in fixtures:
validate_fixture_schema(f)
print("porting-fixtures-ok")
def test_dependency_fixtures() -> None:
"""Load and verify all dependency fixtures."""
fixtures = load_fixtures(DEPENDENCY_FILENAME)
assert len(fixtures) >= 6
for f in fixtures:
validate_fixture_schema(f)
print("dependency-fixtures-ok")
def test_api_fixtures() -> None:
"""Load and verify all API surface fixtures."""
fixtures = load_fixtures(API_FILENAME)
assert len(fixtures) >= 6
for f in fixtures:
validate_fixture_schema(f)
print("api-fixtures-ok")
def test_cross_file_fixtures() -> None:
"""Load and verify all cross-file fixtures."""
fixtures = load_fixtures(CROSS_FILE_FILENAME)
assert len(fixtures) >= 5
for f in fixtures:
validate_fixture_schema(f)
print("cross-file-fixtures-ok")
def test_circular_fixtures() -> None:
"""Load and verify all duplicate import fixtures."""
fixtures = load_fixtures(CIRCULAR_FILENAME)
assert len(fixtures) >= 5
for f in fixtures:
validate_fixture_schema(f)
print("circular-fixtures-ok")
def test_run_porting() -> None:
"""Run all porting fixtures through their expected rules."""
fixtures = load_fixtures(PORTING_FILENAME)
for fixture in fixtures:
result = run_fixture(fixture)
verify_fixture_result(fixture, result)
print("run-porting-ok")
def test_run_dependency() -> None:
"""Run all dependency fixtures through their expected rules."""
fixtures = load_fixtures(DEPENDENCY_FILENAME)
for fixture in fixtures:
result = run_fixture(fixture)
verify_fixture_result(fixture, result)
print("run-dependency-ok")
def test_run_api() -> None:
"""Run all API surface fixtures through their expected rules."""
fixtures = load_fixtures(API_FILENAME)
for fixture in fixtures:
result = run_fixture(fixture)
verify_fixture_result(fixture, result)
print("run-api-ok")
def test_run_cross_file() -> None:
"""Run all cross-file fixtures through their expected rules."""
fixtures = load_fixtures(CROSS_FILE_FILENAME)
for fixture in fixtures:
result = run_fixture(fixture)
verify_fixture_result(fixture, result)
print("run-cross-file-ok")
def test_run_circular() -> None:
"""Run all duplicate import fixtures through their expected rules."""
fixtures = load_fixtures(CIRCULAR_FILENAME)
for fixture in fixtures:
result = run_fixture(fixture)
verify_fixture_result(fixture, result)
print("run-circular-ok")
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
_COMMANDS: dict[str, Callable[[], None]] = {
"porting_fixtures": test_porting_fixtures,
"dependency_fixtures": test_dependency_fixtures,
"api_fixtures": test_api_fixtures,
"cross_file_fixtures": test_cross_file_fixtures,
"circular_fixtures": test_circular_fixtures,
"run_porting": test_run_porting,
"run_dependency": test_run_dependency,
"run_api": test_run_api,
"run_cross_file": test_run_cross_file,
"run_circular": test_run_circular,
}
if __name__ == "__main__":
if len(sys.argv) < 2:
print(
"Usage: helper_semantic_validation_suite.py <command>",
file=sys.stderr,
)
sys.exit(1)
cmd = sys.argv[1]
if cmd not in _COMMANDS:
print(f"Unknown command: {cmd}", file=sys.stderr)
sys.exit(1)
try:
_COMMANDS[cmd]()
except Exception as exc:
print(f"FAILED: {exc}", file=sys.stderr)
sys.exit(1)