mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 22:44:59 +01:00
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.
This commit is contained in:
@@ -158,9 +158,10 @@ def build_scenery(case: dict, game_dir: Path, case_name: str, vehicle: str) -> s
|
||||
# events of the case go in before it (read after it they never fire), trainsets after it
|
||||
# (placed before it they stand on unlinked track and derail at once)
|
||||
before, trainsets = split_trainsets(fragment)
|
||||
if case.get("test_config"):
|
||||
# settings of the test mode (test.timeout and so on), read like any other config block
|
||||
before = "config\n" + "".join(line + "\n" for line in case["test_config"]) + "endconfig\n" + before
|
||||
# settings of the test mode, read like any other config block: the case's vehicle is the train under test,
|
||||
# whose consist the pass and the standstill wait for, and the case's own (test.timeout and so on)
|
||||
config = [f"test.vehicle {vehicle}", *case.get("test_config", [])]
|
||||
before = "config\n" + "".join(line + "\n" for line in config) + "endconfig\n" + before
|
||||
header = f"\n// ---- autotest: {case_name} ----\n"
|
||||
firstinit = re.search(r"(?im)^\s*firstinit\b", text)
|
||||
if firstinit:
|
||||
@@ -526,6 +527,9 @@ def run_case(name: str, exe: Path, game_dir: Path, timespeed: float, watch: bool
|
||||
shutil.move(path, out / f"{kind}.txt")
|
||||
if physicslog.exists():
|
||||
shutil.move(physicslog, out / physicslog.name)
|
||||
# other trains of the case with a driver, named <something>_<vehicle>, log too
|
||||
for other in physicslog.parent.glob(f"*_{vehicle}.dat"):
|
||||
shutil.move(other, out / other.name)
|
||||
|
||||
ok = True
|
||||
sim_t = result.rows[-1][COL_TIME] if result.rows else 0.0
|
||||
|
||||
Reference in New Issue
Block a user