18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-14 11:13:34 +01:00
Commit Graph

4 Commits

Author SHA1 Message Date
jerrrrycho
8fb596f218 fix(simulation): any exception ends a test run with error, other runs as on master
main() tells a test run (--test) apart before anything runs. Only a test run
catches every exception and installs a std::terminate handler, both ending the
run with the error code and a test: line; any other run keeps master's
exception handling, so on Linux an uncaught runtime_error aborts at the throw
site again.

A test run doesn't start the Discord RPC thread: it published the test
scenery as the player's presence and held the closing up to 5 s.

run.py drops a case scenery's .sbt cache after a run cut short (wall_timeout,
error, a crash, killed by run.py), which could have been writing it.

The -edit branch of the test command line parser had no effect (a token that
isn't an option is ignored either way) and is gone; its test checks what can
be seen instead.
2026-11-08 19:46:16 +01:00
jerrrrycho
e5aafd154f feat(simulation): the pass and the standstill wait for the train under test only
Both waited for every vehicle of the scenery to stand still, so on a scenery
with AI traffic a test could pass only when the traffic happened to stand too,
and the standstill end hardly ever came.

A test scenery names the train under test with test.vehicle <name> in its
config block (once for each train, if several): the pass and the standstill wait
for the consists of these vehicles as they are at the moment, so a train the
tested one couples to counts with it. A name the scenery doesn't have ends the
test with the error code. Without test.vehicle every vehicle counts, as before.
A signal passed at danger counts for every train either way.

run.py puts the case's lead vehicle into test.vehicle. test_mode_standstill_traffic
has the train under test standing on track 2 of Stacja1 while AI traffic leaves
track 1 on the timetable: it ends on its 100 s standstill, where counting every
vehicle runs into the 300 s timeout. Physicslogs of the other trains of a case
(<something>_<vehicle>) are moved out of the game dir too.
2026-11-08 11:39:52 +01:00
jerrrrycho
03a417c7b0 feat(simulation): a real time watchdog ends a test run that hangs
A test run that hung, in the loading or anywhere else, waited until whoever
started it killed it. A watchdog thread now ends a run still going test.wall_timeout
seconds of real time after the start of the simulator, loading included: it says
`test: timeout ... still running after N s of real time` and quits with the
timeout code, whatever the main thread is doing, with no dialog. A test that has
ended but whose simulator doesn't close ends with its own result.

The limit is test.wall_timeout (settings, the scenery's config block) or
--test-wall-timeout, which wins. Not given, it is test.timeout + 600 s: ten
minutes for the loading, and a simulation that runs at least as fast as real
time is never cut short. test.timeout 0 means no watchdog unless the limit is
given; test.wall_timeout 0 turns it off.

run.py passes the case's timeout as --test-wall-timeout and kills a simulator
only 30 s after it. A timeout from the watchdog counts as wall_timeout there, so
a run that hung doesn't pass a case expecting the simulation time to run out;
test_mode_wall_timeout ends while loading on a limit of 2 s.
2026-11-08 11:33:36 +01:00
jerrrrycho
486a714f52 refactor(simulation): the rules of the test mode in a file of their own, with unit tests
The command line options of the test mode and the end conditions checked after
each frame are now plain functions in simulation/simulationtestrules.cpp, which
needs nothing of the running simulation: parse_test_command_line() and
evaluate_frame(). The file is part of the core library, so the unit tests check
them (tests/unit/test_test_mode.cpp): the --test-timeout value, values of other
options not taken for options, a pass that waits for the stop, the standstill,
the timeout. test_manager only gathers what a frame brought and acts on the
verdict. No change in behaviour.
2026-11-08 11:20:52 +01:00