mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-10-15 17:19:55 -07:00
forgetest: every machine action a test takes is declared
The queues route a test by its kind and its declared actions: an auto test runs unattended with or without the bench fixture, and an operator test whose actions the fixture covers runs unattended only while it does. exthost.events opens and closes the lid through Context.act but was declared auto with no actions, so the unattended queue ran it with no fixture on the network, and it waited 180 s for a person who was not there: the fx29 campaign (image 20261010213702) ended on "lid open was not seen on the machine within 180 s" with forgefixture.local silent to mDNS and 172.16.1.171 silent to ping. - exthost.events: operator, actions lid, with the operator's steps. - events.button-telemetry: the same defect with the button; operator, actions button, with the operator's steps. - setup.check-switches: declares interlock beside lid and button; the check works the interlock loop on a Pro. test_fixture's new CatalogTests case reads every catalog test's source and fails a test that calls Context.act on a channel it does not declare, or that is auto and calls it at all. It found these three and no other. Fingerprints: the three decorators are each test's own text, so these three move and no other (diffed across the change, 128 tests). Proof: the whole host suite passes (509 tests) and pyflakes finds no undefined name. RoutingTests already prove the routing these declarations feed: an operator test the fixture covers moves to the unattended queue, one it does not stays attended, and with no fixture the routing is the old one. Acceptance: the change is the three tests' declarations; with the fixture up each runs unattended through it as before, and with the fixture down each stays in the attended list instead of stranding the unattended queue.
This commit is contained in:
@@ -49,8 +49,11 @@ def _reader(sock, seen, stop):
|
||||
|
||||
|
||||
@test("events.button-telemetry", title="The event stream tells a press of the button, and the telemetry",
|
||||
subsystem="forgectrl", kind="auto", mode="grbl", est_min=2,
|
||||
subsystem="forgectrl", kind="operator", mode="grbl", est_min=2,
|
||||
covers=[("forgectrl", "src/events.*"), ("forgectrl", "src/main.c"), ("forgectrl", "src/status.*")],
|
||||
actions=["button"],
|
||||
steps=["The machine idle; you will be told to press the button once.",
|
||||
"Nothing moves and nothing fires: nothing is waiting for the press."],
|
||||
description="A stream opened at forgectrl's read-only listener gets a telemetry.tick within 12 s, "
|
||||
"and it is what the daemon already holds: the cooling phase, the verdict, fire_ok, the "
|
||||
"two coolant temperatures, the controller's state, and the lid, with no sensor read of "
|
||||
|
||||
@@ -1542,10 +1542,12 @@ def hold_pause_tier(ctx):
|
||||
# ------------------------------------------------- the operator's door
|
||||
|
||||
@test("exthost.events", title="The machine's events reach a package, over one subscription",
|
||||
subsystem="exthost", kind="auto", hardware="takeover", est_min=6,
|
||||
subsystem="exthost", kind="operator", hardware="takeover", est_min=6,
|
||||
covers=[("forgeext", "src/evfeed.*"), ("forgeext", "src/api.*"), ("forgeext", "src/run.*"),
|
||||
("forgectrl", "src/events.*"), ("forgectrl", "src/main.c")],
|
||||
requires=["exthost.service"],
|
||||
requires=["exthost.service"], actions=["lid"],
|
||||
steps=["Start with the lid closed; you will be told to open it, then close it again.",
|
||||
"Nothing moves and the laser is not involved."],
|
||||
description="The reference package is installed with the events capability. The host holds one "
|
||||
"subscription to forgectrl's stream for every package that wants events, and none when "
|
||||
"no package does: with the service running the status file says the stream is connected "
|
||||
|
||||
@@ -121,7 +121,7 @@ def run_check(ctx, wid, on_prompt, timeout_s):
|
||||
@test("setup.check-switches", title="The switches check follows the lid and the button",
|
||||
subsystem="setup", kind="operator", est_min=3,
|
||||
covers=DARK_COVERS + [("forgectrl", "src/status.c")],
|
||||
requires=["forgectrl.auth"], actions=["lid", "button"],
|
||||
requires=["forgectrl.auth"], actions=["lid", "button", "interlock"],
|
||||
description="POST /wiz/switches/start; the check asks for the lid to open and close and for "
|
||||
"a press, each as a 'wait' prompt that the switch edge itself answers; the bench "
|
||||
"fixture works the lid and the button. On a Basic or Plus the interlock loop reads "
|
||||
|
||||
@@ -314,6 +314,24 @@ class CatalogTests(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
catalog.test("z.auto", title="t", subsystem="z", hands=("app",))(lambda ctx: None)
|
||||
|
||||
def test_every_action_a_test_takes_is_declared(self):
|
||||
# The queues route a test by its kind and its actions: an auto test
|
||||
# runs unattended with or without a fixture, and an operator test
|
||||
# whose actions the fixture covers runs unattended only while it
|
||||
# does. A test that acts on the lid, the interlock or the button
|
||||
# without saying so runs unattended with no fixture and waits for a
|
||||
# person who is not there.
|
||||
import inspect
|
||||
import re
|
||||
from forgetest import catalog
|
||||
bad = []
|
||||
for t in catalog.all_tests(catalog.load_suite()):
|
||||
src = inspect.getsource(t.fn)
|
||||
taken = set(re.findall(r'ctx\.act\(\s*"(\w+)"', src))
|
||||
if taken and (t.kind == "auto" or not taken <= set(t.actions)):
|
||||
bad.append("%s (%s) acts on %s, declares %s" % (t.id, t.kind, sorted(taken), list(t.actions)))
|
||||
self.assertEqual(bad, [])
|
||||
|
||||
|
||||
class StubFixture:
|
||||
"""What the runner needs of a fixture, scripted."""
|
||||
|
||||
Reference in New Issue
Block a user