mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 11:06:03 +01:00
test: scenario tests run in the simulator's test mode and check its exit code
run.py starts eu07 with --test (and --test-timeout <duration> for cases that record a fixed time) and compares the result from the exit code with the case's expect key, before the physicslog checks. The 14 cases take about 30 s with -j 4 instead of minutes. --watch keeps the old windowed run. New case keys: expect, test_config (lines of a config block), track_events (lines added to a track of the base scenery, e.g. event0 test_pass). New cases show each end of the test mode: test_mode_pass, _signal_passed_at_danger, _timeout and _standstill. The slippery rail cases slide past the red signal, which now ends a test, so they set test.fail_if_stop_overran no. README documents the test mode for scenery authors.
This commit is contained in:
@@ -4,6 +4,9 @@
|
||||
"time": "10:34",
|
||||
"track_friction": 0.03,
|
||||
"fragment": "td_red_signal_moving.scn",
|
||||
"test_config": [
|
||||
"test.fail_if_stop_overran no"
|
||||
],
|
||||
"vars": {
|
||||
"velocity": "30",
|
||||
"consist": [
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
"time": "10:34",
|
||||
"track_friction": 0.03,
|
||||
"fragment": "td_red_signal_moving.scn",
|
||||
"test_config": [
|
||||
"test.fail_if_stop_overran no"
|
||||
],
|
||||
"vars": {
|
||||
"velocity": "30",
|
||||
"consist": [
|
||||
|
||||
8
tests/scenarios/cases/td_red_signal_pass.scn
Normal file
8
tests/scenarios/cases/td_red_signal_pass.scn
Normal file
@@ -0,0 +1,8 @@
|
||||
// added by tests/scenarios/run.py to td.scn, whose own trainsets were removed.
|
||||
// like td_red_signal.scn (no route, the exit signal stacja1_j about 150 m ahead stays at stop),
|
||||
// with the test mode's pass event: the case puts it as event0 on tor1k, the track in front of
|
||||
// the signal, so it runs once the train stands there. the test passes when every vehicle stopped.
|
||||
event test_pass UpdateValues 0 __test.result stopped_before_stacja1_j 1 * endevent
|
||||
trainset td/rozklad tdo_n1734 0.0 0.1
|
||||
{{consist}}
|
||||
endtrainset
|
||||
31
tests/scenarios/cases/test_mode_pass.json
Normal file
31
tests/scenarios/cases/test_mode_pass.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"description": "Test mode, pass: EU07 on td.scn with no route set stops before the exit signal stacja1_j; event0 of the track there reports the pass, and the test ends as passed once the train stands.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_red_signal_pass.scn",
|
||||
"track_events": {
|
||||
"tor1k": "event0 test_pass"
|
||||
},
|
||||
"vars": {
|
||||
"consist": "node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic"
|
||||
},
|
||||
"expect": "pass",
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "starts",
|
||||
"min_speed": 5,
|
||||
"within": 150
|
||||
},
|
||||
{
|
||||
"type": "stops",
|
||||
"moving_speed": 5,
|
||||
"stop_speed": 0.5,
|
||||
"hold": 0.5
|
||||
},
|
||||
{
|
||||
"type": "distance",
|
||||
"max": 150
|
||||
}
|
||||
]
|
||||
}
|
||||
22
tests/scenarios/cases/test_mode_signal_passed_at_danger.json
Normal file
22
tests/scenarios/cases/test_mode_signal_passed_at_danger.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"description": "Test mode, signal passed at danger: EU07 on td.scn with no route set starts at 60 km/h about 150 m before the exit signal stacja1_j at stop. Its AI driver is still preparing the engine and doesn't brake, and the run ends when the train passes the signal.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_red_signal_moving.scn",
|
||||
"vars": {
|
||||
"velocity": "60",
|
||||
"consist": "node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic"
|
||||
},
|
||||
"expect": "signal_passed_at_danger",
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "max_speed",
|
||||
"limit": 61
|
||||
},
|
||||
{
|
||||
"type": "distance",
|
||||
"min": 140
|
||||
}
|
||||
]
|
||||
}
|
||||
26
tests/scenarios/cases/test_mode_standstill.json
Normal file
26
tests/scenarios/cases/test_mode_standstill.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"description": "Test mode, standstill: EU07 on td.scn with no route set stops before the exit signal stacja1_j at stop and stays; nothing reports a result, so the test ends once every vehicle stood still for test.standstill 120 seconds (the train waits about 70 s before it pulls off, so less would end it before the start).",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_red_signal.scn",
|
||||
"test_config": [
|
||||
"test.standstill 120"
|
||||
],
|
||||
"vars": {
|
||||
"consist": "node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic"
|
||||
},
|
||||
"expect": "standstill",
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "stops",
|
||||
"moving_speed": 5,
|
||||
"stop_speed": 0.5,
|
||||
"hold": 5
|
||||
},
|
||||
{
|
||||
"type": "distance",
|
||||
"max": 150
|
||||
}
|
||||
]
|
||||
}
|
||||
21
tests/scenarios/cases/test_mode_timeout.json
Normal file
21
tests/scenarios/cases/test_mode_timeout.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"description": "Test mode, timeout: EU07 on td.scn with no route set pulls off towards the exit signal stacja1_j at stop; nothing reports a result and test.timeout 90 from the scenery's config block runs out first.",
|
||||
"base_scenery": "td.scn",
|
||||
"time": "10:34",
|
||||
"fragment": "td_red_signal.scn",
|
||||
"test_config": [
|
||||
"test.timeout 90"
|
||||
],
|
||||
"vars": {
|
||||
"consist": "node -1 0 {{vehicle}} dynamic pkp\\4e_v1 4e-004 4e 0 headdriver 0 0 enddynamic"
|
||||
},
|
||||
"expect": "timeout",
|
||||
"timeout": 600,
|
||||
"checks": [
|
||||
{
|
||||
"type": "starts",
|
||||
"min_speed": 5,
|
||||
"within": 90
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user