Skip to content

🧹 Refactor uf2 tests to remove unsafe unwrap() - #330

Open
undivisible wants to merge 2 commits into
masterfrom
refactor/uf2-unwrap-3432215088667041043
Open

🧹 Refactor uf2 tests to remove unsafe unwrap()#330
undivisible wants to merge 2 commits into
masterfrom
refactor/uf2-unwrap-3432215088667041043

Conversation

@undivisible

@undivisible undivisible commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

🎯 What:
Replaced unwrap() calls on slice to array conversions (try_into()) with the ? operator in the tests inside in-cli/src/native_emit/uf2.rs. The test function signatures were updated to return Result<(), Box<dyn std::error::Error>>.

💡 Why:
Using unwrap() can lead to unexpected panics, making tests fail ungracefully. Updating the code to use robust error handling via ? is standard practice and improves the overall maintainability and safety of the test suite.

Verification:

  1. Formatted code with cargo fmt.
  2. Linted code with cargo clippy --all-targets --features extended --locked -- -D warnings.
  3. Ran module specific tests via cargo test native_emit.
  4. Ran full test suite via cargo test.
  5. Ran integration test suite via IN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in test. All test results verified successfully.

Result:
The test suite is now safer and more idiomatic. Code health issues related to unsafe unwrap() usage in these test functions are fully resolved without any regressions in functionality.


PR created automatically by Jules for task 3432215088667041043 started by @undivisible


Note

Low Risk
Test-only changes in UF2 encoding tests with no production code or runtime behavior impact.

Overview
Refactors UF2 encoder unit tests in uf2.rs so slice-to-array conversions use ? instead of unwrap(), and the two affected tests return Result<(), Box<dyn std::error::Error>> with Ok(()) on success.

Behavior and assertions are unchanged; this is test-only ergonomics and panic avoidance on conversion failures. The rejects_empty test is untouched.

Reviewed by Cursor Bugbot for commit d9cebc5. Configure here.

Updated test signatures in `in-cli/src/native_emit/uf2.rs` to return `Result<(), Box<dyn std::error::Error>>` and replaced unsafe `unwrap()` calls on `try_into()` with the `?` operator.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4ea30e3a-7c03-476f-b7c1-568e2a3536e0)

@mergify

mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Updated test signatures in `in-cli/src/native_emit/uf2.rs` to return `Result<(), Box<dyn std::error::Error>>` and replaced unsafe `unwrap()` calls on `try_into()` with the `?` operator.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_4c7b2a77-e2f3-4818-9b71-39d234556e3b)

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