mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
This fuzz test generates random inputs for waypoint solvers to check if they can find a solution. If they can't, the debug info for the solver is dumped to the testcases directory. Another test loads those test cases, creates a solver from them, and checks that a solution is found. Obviously it won't be immediately, but it's a starting point for fixing the bug and serves as a regression test afterward.
24 lines
778 B
Python
24 lines
778 B
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from game.flightplan.waypointsolverloader import WaypointSolverLoader
|
|
|
|
THIS_DIR = Path(__file__).parent
|
|
TEST_CASES_DIR = THIS_DIR / "testcases"
|
|
|
|
# Set to True to regenerate the debug files for each test case. After doing this, format
|
|
# the test cases with `npx prettier -w tests/flightplan/testcases` for readability.
|
|
UPDATE_TEST_CASES = False
|
|
|
|
|
|
@pytest.mark.parametrize("test_case", TEST_CASES_DIR.glob("**/solver.json"))
|
|
def test_waypoint_solver_regression_tests(test_case: Path) -> None:
|
|
loader = WaypointSolverLoader(test_case)
|
|
solver = loader.load()
|
|
if UPDATE_TEST_CASES:
|
|
solver.set_debug_properties(test_case.parent, loader.terrain)
|
|
solver.solve()
|
|
if UPDATE_TEST_CASES:
|
|
solver.dump_debug_info()
|