Skip to content

Use Rust to test Pica directly - #168

Open
sameer wants to merge 5 commits into
refactorfrom
replace-pytest-with-rust-tests
Open

sameer wants to merge 5 commits into
refactorfrom
replace-pytest-with-rust-tests

Conversation

@sameer

@sameer sameer commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Previously, Pica relied on a PyTest suite to test functionality that really should have been checked directly in unit and integration tests.

@sameer
sameer changed the base branch from main to refactor November 23, 2026 20:55

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a major refactoring of the codebase, extracting device capabilities, core operations, session configuration, session control, DL-TDoA, and data transfer logic into dedicated submodules, while replacing Python-based integration tests with native Rust integration tests. A review comment correctly identifies the use of the unstable let_chains feature in src/ranging.rs, which would prevent compilation on stable Rust, and provides an actionable suggestion to rewrite it using standard nested if let or combinators.

I am having trouble creating individual review comments. Click here to see my feedback.

src/ranging.rs (357-372)

medium

The use of the unstable let_chains feature (&& let) will prevent compilation on stable Rust compilers. To maintain compatibility with stable Rust, it is recommended to rewrite this logic using standard if let nesting or Option::and_then combinators.

        let peer_handle = if session.can_start_data_transfer() {
            session.data_transfer.as_ref().and_then(|data_transfer| {
                let dst_mac_address = data_transfer.dst_mac_address;
                self.devices
                    .values()
                    .find(|peer_entry| {
                        peer_entry.device.handle != device_handle
                            && peer_entry
                                .device
                                .can_receive_data_transfer(session_id, dst_mac_address)
                    })
                    .map(|peer_entry| peer_entry.device.handle)
            })
        } else {
            None
        };

@sameer
sameer marked this pull request as draft November 23, 2026 21:01
Remove internal Instant::now calls from the Pica state machine by taking now in handle_packet and tick, exposing next_deadline, and initializing boot_time lazily on CoreDeviceResetCmd while keeping OS clock reads at the binary and FFI edges.
@sameer
sameer force-pushed the replace-pytest-with-rust-tests branch from b833c9f to 262c5ca Compare November 23, 2026 21:45
@sameer
sameer marked this pull request as ready for review November 23, 2026 21:46
@sameer
sameer added this pull request to stack #169 November 23, 2026 21:46
Replace pytest coverage with deterministic unit tests across device, session, app_config, ranging, dl_tdoa, and data_transfer, plus sans-I/O integration tests in tests/.
Drop the legacy Python pytest suite, GitHub Actions pytest steps, and README pytest instructions now that equivalent Rust tests are in place.
@sameer
sameer force-pushed the replace-pytest-with-rust-tests branch from 262c5ca to c3fa56b Compare November 23, 2026 21:59
@sameer
sameer requested a review from AlpineOolong November 23, 2026 22:00
Remove map-storage, hardcoded version, and duplicate integration tests while retaining CUSTOM_CAPS codec coverage and adding FiRa 2.0 capability contract checks plus unit tests for reset timestamp clearing, non-command packet filtering, missing mandatory app config rejection, resume after suspend, and combined proximity-AoA edge triggers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant