🧹 Fix unsafe unwrap() usage in native_emit::uf2 tests - #324
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Bugbot couldn't run - usage limit reachedBugbot 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_4649b62b-7081-4c89-9026-7bdb5176534f) |
|
Tick the box to add this pull request to the merge queue (same as
|
🎯 What:
Replaced
unwrap()andexpect()usage inin-cli/src/native_emit/uf2.rstest assertions with safe error propagation using the?operator by changing the test functions to returnResult<(), Box<dyn std::error::Error>>.💡 Why:
Unsafe unwrap usage inside tests is generally acceptable, but converting test signatures to return a
Resultallows leveraging the?operator. This makes the testing code more idiomatic, prevents hard panics, and aligns with standard Rust error handling practices.✅ Verification:
cargo test -p inauguration native_emit::uf2passes correctly.cargo test.IN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in test.cargo fmtandcargo clippy.✨ Result:
The UF2 tests are cleaner and handle
try_into()andencode_uf2()errors gracefully without relying on panickingunwrap()mechanisms.PR created automatically by Jules for task 10215781581313917983 started by @undivisible
Note
Low Risk
Test-only refactors in
uf2.rs; no changes toencode_uf2orwrite_uf2behavior.Overview
Updates the
encodes_single_block_with_familyandsplits_large_payloadtests inuf2.rsso they returnResult<(), Box<dyn std::error::Error>>instead of panicking on failure paths.encode_uf2and slicetry_into()failures now propagate with?, and successful runs end withOk(()). The empty-payload test still usesexpect_errfor the error case. Production UF2 encoding is unchanged.Reviewed by Cursor Bugbot for commit d592f65. Configure here.