diff --git a/forgetest/forgetest/runner.py b/forgetest/forgetest/runner.py index 7a76787..27cd4fe 100644 --- a/forgetest/forgetest/runner.py +++ b/forgetest/forgetest/runner.py @@ -485,6 +485,7 @@ class Context: rec["fixture_error"] = str(e) self.log("ARM press: fixture failed (%s) - asking the operator", e) self.notice(text) + self._clear_when_taken() return False rec["by"] = "fixture" self.log("ARM press by the fixture, at the machine's own press prompt") @@ -566,6 +567,7 @@ class Context: if lit is None: self.log("ARM: the button never lit within %d s - asking the operator", lit_timeout) self.notice(text) + self._clear_when_taken() return try: fixture.act("button", "press") @@ -573,6 +575,7 @@ class Context: self.log("ARM press: fixture failed (%s) - asking the operator", e) rec["fixture_error"] = str(e) self.notice(text) + self._clear_when_taken() return rec["by"] = "fixture" rec["took_s"] = round(lit, 2) diff --git a/forgetest/tests/test_fixture.py b/forgetest/tests/test_fixture.py index 0e114fb..1346057 100644 --- a/forgetest/tests/test_fixture.py +++ b/forgetest/tests/test_fixture.py @@ -594,6 +594,38 @@ class RoutingTests(unittest.TestCase): time.sleep(0.02) self.assertFalse(watching()) self.assertIsNotNone(run.notice) # the finished run's notice is left as it was + # A press the fixture could not make is asked of the operator, and + # that notice comes down at the press like any other: press_now and + # arm_press with the box refusing, and arm_press with the button + # never lit for the box. + self.stub.arm_press = True + self.stub.fail = True + run = Run("test", "r.live", "r.live") + ctx = Context(run, self.runner, self.reg["r.live"]) + + def settles(up): + deadline = time.time() + 2 + while (run.notice is not None) != up and time.time() < deadline: + time.sleep(0.02) + return (run.notice is not None) == up + lit["v"] = True # the machine waits for the press + self.assertFalse(ctx.press_now()) # the box is off: the operator is asked + self.assertIsNotNone(run.notice) + time.sleep(0.2) # lit: the arm waits for the press + lit["v"] = False # the operator's press is taken + self.assertTrue(settles(False)) + lit["v"] = True + self.assertTrue(ctx.arm_press()) # the fixture is asked, and refuses + self.assertTrue(settles(True)) + time.sleep(0.2) + lit["v"] = False + self.assertTrue(settles(False)) + self.assertTrue(ctx.arm_press(lit_timeout=0)) # the button never lit for the fixture + self.assertTrue(settles(True)) + lit["v"] = True + time.sleep(0.2) + lit["v"] = False + self.assertTrue(settles(False)) finally: runner_mod.hw.button_lit = saved