Repository navigation
test: prove the controller stepped before refuting its output - #120
Merged
Merged
Conversation
jimsynz
force-pushed
the
test/event-driven-tests
branch
from
October 13, 2026 22:18
7397803 to
5f37809
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was timing-based
Three tests in
test/bb/pid/controller_test.exsusedrefute_receive {:bb, [:actuator, :base_link, :joint1, :servo], _}, 50to stand in for "the controller didn't publish":Fifty milliseconds is about five ticks at 100 Hz, but nothing proved the inputs had been consumed or that a tick had stepped in that window. Under load the tests would pass without testing anything.
What they wait on now
A shared
refute_output_after_a_step/0helper::sys.get_state/1on the controller, so the published inputs have been handled (BB.PubSub.publish/3sends from the test process).[:bb, :loop, :tick]telemetry handler filtered onrobot: TestRobot, path: [:test_pid]. It is attached after the sync, so any event it reports comes from a tick that saw the inputs.BB.Looponly emits on ticks with adt, which are the ones that reachstep/2.assert_receives that event (1 s upper bound), then:sys.get_state/1again so that tick'sstep/2has finished. Anything it published reached the test before the reply.refute_receivedthe output, which checks the mailbox without waiting.As a check that the helper isn't vacuous, I temporarily added a measurement to the setpoint-only test. It then failed on
refute_received3/3 times. No lib changes.The
assert_receive …, 100calls elsewhere in the file are upper bounds on an output that must arrive, so I left them alone.Left
Nothing.
Results
mix test test/bb/pid/controller_test.exs:174 :201 :218 --seed 0×10: 10/10 runs passed (3 tests each).mix check --no-retry: all green, before and after the change. No pre-existing failures.