18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 01:34:59 +01:00

test(scenarios): automatic coupler cases (#86)

Re-lands #288, which was merged into feat/exe-test-mode after that
branch had already gone to master, so master never got it.

Two EN57-2000 units on td.scn, one standing, the other rolling into it
without a driver. At 50 km/h their automatic couplers mustn't catch: the
log has to show the collision and the derailment. At 4 km/h they couple
and nothing collides. Nothing reports a result, so both cases end on the
60 s test timeout.

run.py gets log_contains / log_lacks checks on the run's log.txt, and an
"ini" case key for extra eu07.ini lines (here crashdamage yes). The log
checks fail when log.txt is missing or empty: with no log text log_lacks
would pass without checking anything.
This commit is contained in:
jerrrrycho
2026-11-08 21:06:11 +01:00
parent 10c7527a64
commit 85119cc110
5 changed files with 101 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
{
"description": "Issue #86, the control case: an EN57-2000 unit without a driver rolls at 4 km/h into a standing one on td.scn. Their automatic couplers catch, nothing collides nor derails; nothing reports a result, so the run ends on the 60 s test timeout.",
"base_scenery": "td.scn",
"ini": ["crashdamage yes"],
"fragment": "td_automatic_coupler_hit.scn",
"vars": {
"velocity": "4",
"offset": "30"
},
"expect": "timeout",
"duration": 60,
"timeout": 300,
"checks": [
{ "type": "log_lacks", "pattern": "collided" },
{ "type": "log_lacks", "pattern": "derailed" }
]
}

View File

@@ -0,0 +1,17 @@
{
"description": "Issue #86: an EN57-2000 unit without a driver runs at 50 km/h into a standing one on td.scn. Their automatic couplers mustn't catch at that speed: the units collide and derail; the run ends on the 60 s test timeout.",
"base_scenery": "td.scn",
"ini": ["crashdamage yes"],
"fragment": "td_automatic_coupler_hit.scn",
"vars": {
"velocity": "50",
"offset": "0"
},
"expect": "timeout",
"duration": 60,
"timeout": 300,
"checks": [
{ "type": "log_contains", "pattern": "Bad driving: autotest_\\S+ and autotest_\\S+ collided" },
{ "type": "log_contains", "pattern": "Bad driving: autotest_\\S+ derailed" }
]
}

View File

@@ -0,0 +1,19 @@
// added by tests/scenarios/run.py to td.scn, whose own trainsets were removed.
// two EN57-2000 units, which have automatic couplers at their cab ends, on the straight track 1
// of Stacja1: one stands where td.scn keeps its timetable train, with an AI driver and no
// timetable, so it stays put and logs its physics; the other has no driver and rolls into it at
// {{velocity}} km/h, its front coupler hitting the rear one of the first.
// a trainset's first vehicle stands {{offset}} m past point 1 of its track, the rest towards point 1,
// and a positive velocity runs towards point 2. tdo_n1734 is the 100 m track after tdo_n1725, a unit
// is 64.4 m long: the first one reaches back to 35.6 m into tdo_n1725, so the gap is 35.6 - offset m.
trainset none tdo_n1734 0.0 0.0
node -1 0 {{vehicle}} dynamic pkp\en57-2000_v1 en57-2040_ra 6ba 0 headdriver 255 0 enddynamic
node -1 0 {{vehicle}}_s dynamic pkp\en57-2000_v1 en57-2040_s 6bs 0 nobody 255 0 enddynamic
node -1 0 {{vehicle}}_rb dynamic pkp\en57-2000_v1 en57-2040_rb 6bb 0 nobody 0 0 enddynamic
endtrainset
trainset none tdo_n1725 {{offset}} {{velocity}}
node -1 0 {{vehicle}}_hit_ra dynamic pkp\en57-2000_v1 en57-2040_ra 6ba 0 nobody 255 0 enddynamic
node -1 0 {{vehicle}}_hit_s dynamic pkp\en57-2000_v1 en57-2040_s 6bs 0 nobody 255 0 enddynamic
node -1 0 {{vehicle}}_hit_rb dynamic pkp\en57-2000_v1 en57-2040_rb 6bb 0 nobody 0 0 enddynamic
endtrainset