Repository navigation
Tests: a rejected tracking query gives tracking: null, not a failed status - #169
Merged
Merged
Conversation
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>
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
force-pushed
the
fix/152-test-rejected-tracking
branch
from
November 13, 2026 12:29
27728fc to
dc20a5a
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.
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 answersxu_get,xu_set,get_ctrlandctrl_rangefrom 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:Devicegets a test-onlyscriptfield, a test-onlyDevice::scriptedconstructor and a#[cfg(test)]early return at the top of those four methods. Withoutcfg(test)the file compiles to the same code as before.crates/obsbot-device/src/legacy/full_status.rs: three tests onfull_status_withwith the scripted camera:Okwithtracking: Noneand the other fields filled (status, zoom factor and absolute, live pose, microphone volume, firmware, model);tracking(shows the first test sees the arm, not a camera that never reports tracking);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, butfull_status_withalso 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_guard1,cli_surface2).tests/byte_guard.rs,tests/cli_surface.rsand their fixtures are unchanged.full_status_with,Err(Error::NoAnswer(_) | Error::Rejected(..)) => Nonechanged toErr(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.Err(_) => None. The "any other tracking error" test fails; the other two pass. Restored: all pass.