Skip to content

Tests: a rejected tracking query gives tracking: null, not a failed status - #169

Merged
nofuturekid merged 4 commits into
rebuildfrom
fix/152-test-rejected-tracking
Nov 13, 2026
Merged

nofuturekid merged 4 commits into
rebuildfrom
fix/152-test-rejected-tracking

Conversation

@nofuturekid

Copy link
Copy Markdown
Collaborator

Fixes #152

Stacked on #167: the branch is built on fix/151-test-rejected-answer, so until #167 lands this pull request also shows its commit. The change of this pull request is the one commit on top (Test that a rejected tracking query gives tracking: null).

What changed

Tests only; no status code and no byte sent to the camera changed.

  • crates/obsbot-device/src/scripted.rs (new, compiled in tests only): a scripted camera. It answers xu_get, xu_set, get_ctrl and ctrl_range from a table: a framed query is answered by command id with a value, a rejection (type 0x89 with a code) or a failed write; a query not in the table is rejected, so a test never waits out the poll.
  • crates/obsbot-device/src/transport/uvc.rs: Device gets a test-only script field, a test-only Device::scripted constructor and a #[cfg(test)] early return at the top of those four methods. Without cfg(test) the file compiles to the same code as before.
  • crates/obsbot-device/src/legacy/full_status.rs: three tests on full_status_with with the scripted camera:
    • a rejected 0x0104 gives Ok with tracking: None and the other fields filled (status, zoom factor and absolute, live pose, microphone volume, firmware, model);
    • an answered 0x0104 fills tracking (shows the first test sees the arm, not a camera that never reports tracking);
    • a failed write of the tracking query still fails the whole read (the arm is not a catch-all).

The issue says the test needs the same scripted reply source as the answer poll. The closure seam of #151 (poll_answer) stops at the poll, but full_status_with also reads status, controls and the detected device, so the scripted source here is the device itself.

Verification (no camera)

  • cargo fmt --check, cargo clippy --all-targets --locked -j 3 -- -D warnings, cargo test --locked -j 3: all pass (125 + 25 unit tests, byte_guard 1, cli_surface 2). tests/byte_guard.rs, tests/cli_surface.rs and their fixtures are unchanged.
  • Mutation 1: in full_status_with, Err(Error::NoAnswer(_) | Error::Rejected(..)) => None changed to Err(Error::NoAnswer(_)) => None. The rejected-tracking test fails (a rejected tracking query does not fail the read: Rejected(260, -3)); the other two pass. Restored: all pass.
  • Mutation 2: the same arm changed to Err(_) => None. The "any other tracking error" test fails; the other two pass. Restored: all pass.

Camera::answer read the device directly, so no test reached its arms. The poll is now
poll_answer, which takes the selector-2 read as a closure and the gap as an argument;
Camera::answer passes the device read and the same 50 ms gap, so what is sent and read
on the camera is unchanged. Tests script the replies: a rejected answer returns
Error::Rejected(command, code) at the first read, an empty answer returns an empty list,
a stale answer runs through all 20 reads to NoAnswer, and failed reads are polled again
until a value arrives.

Fixes #151

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid nofuturekid added the enhancement New feature or request label Nov 13, 2026
nofuturekid and others added 3 commits November 13, 2026 13:24
The test module already gets XU_SIZE through use super::*.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
full_status_with reads the device directly, so no test reached the arm that turns a rejected
or unanswered tracking query (0x0104) into tracking: None. Tests now run it on a scripted
Device (compiled in tests only, answering xu_get, xu_set, get_ctrl and ctrl_range from a
table): a rejected tracking query returns Ok with tracking None and the other fields filled,
an answered one fills tracking, and a failed write still fails the whole read. No status code
and no byte sent to the camera changed.

Fixes #152

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Do not claim how a camera treats an unknown query; the comment now says
what the test double does (type 0x89, code -1) and why.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@nofuturekid
nofuturekid force-pushed the fix/152-test-rejected-tracking branch from 27728fc to dc20a5a Compare November 13, 2026 12:29
@nofuturekid
nofuturekid merged commit dc20a5a into rebuild Nov 13, 2026
6 checks passed
@nofuturekid
nofuturekid deleted the fix/152-test-rejected-tracking branch November 13, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant