mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 20:24:59 +01:00
tests/scenarios/run.py builds a test scenery from a game install's scenery (own trainsets removed, case fragment added), runs eu07 in ghostview with physicslog on, and checks what the vehicle did: starts, max speed, brakes, stops. First case: EU07 on td.scn driven by AI on the td/rozklad timetable, with the Stacja1 exit route set by an event launcher instead of shift+4. eu07 gets a -ini <file> option: an extra settings file read after eu07.ini, so a test run can switch to a window and turn on physicslog without touching the user's config. Local only: scenery and vehicle data are not in the repo.
3.1 KiB
3.1 KiB
Scenario tests
End-to-end checks that run the real simulator on a scenery and look at what a vehicle did: did it start, did it keep to the speed limit, did it brake and stop.
Scenery and vehicle data are not in this repo, so these run against a local game install only, not in CI.
Running
python tests/scenarios/run.py --game-dir "E:/Program Files (x86)/Steam/steamapps/common/MaSzyna"
Python 3.10+, no extra packages. Options:
EU07_GAME_DIRcan replace--game-dir.--exe path/to/eu07.exepicks the build to test; the default is the newestcmake-build-*/bin/Release/eu07*.exe. The build needs the-inicommand line option.- name one or more cases to run only those, e.g.
run.py ... eu07_td_timetable. --timespeed 4runs the simulation faster than real time.
Exit code is 0 when every case passed. Logs of each run (log.txt, errors.txt,
the vehicle's physicslog) land in tests/scenarios/out/<case>/.
How it works
For each case the runner:
- writes
scenery/autotest_<case>.scninto the game dir: the base scenery with its own trainsets removed, the start time changed if the case says so, and the case's.scnfragment added: its trainsets afterFirstInit, everything else (event launchers standing in for keys the scenery expects a player to press, extra events) before it, - starts the simulator with
-s autotest_<case>.scn -v ghostview -ini out/<case>/autotest.ini; ghostview leaves every train to the AI, and the extra ini turns onphysicslog, runs in a 1280x720 window and does not pause when the window loses focus, - waits until
physicslog/<vehicle>.datcoversdurationseconds, then closes the simulator, - runs the checks on the physicslog.
Writing a case
cases/<name>.json:
| key | meaning |
|---|---|
base_scenery |
scenery file in the game's scenery/ dir |
strip_trainsets |
drop the base scenery's trainsets (default true) |
time |
replace the scenery start time, HH:MM |
fragment |
.scn file in cases/ added to the scenery: trainsets after FirstInit (before it they derail on unlinked track), the rest before it (launchers read after it never fire) |
vehicle |
node name of the vehicle whose physicslog is checked |
duration |
seconds of simulation to record |
timeout |
wall-clock seconds before giving up, loading included |
fail_on_errors |
fail when errors.txt is not empty (default false) |
checks |
list of checks, below |
Checks (speeds in km/h, times in seconds of physicslog time):
startsmin_speed,within: reachesmin_speedwithinwithinseconds.max_speedlimit,tolerance: never goes faster thanlimit + tolerance.brakesmin_pressure: after moving off, brake cylinder pressure reachesmin_pressurebar (physicslog pressures are in bar whatever its header says; the brake pipe runs at 5.0).stopsmoving_speed,stop_speed,hold: after reachingmoving_speed, stays at or belowstop_speedforholdseconds.
New check types go in CHECKS in run.py; each gets the physicslog rows and the check's
parameters and returns (passed, detail).