🧹 Refactor tests in cargo_linker to use Result instead of unwrap - #327
🧹 Refactor tests in cargo_linker to use Result instead of unwrap#327undivisible wants to merge 1 commit into
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_336a43d4-dec5-4b41-b8a6-6186369f8f2a) |
|
Tick the box to add this pull request to the merge queue (same as
|
🎯 What:
Replaced
unwrap()calls on std I/O operations (fs::create_dir_all,fs::write) with the?operator in the teststest_compile_cargo_dependencies_finds_and_compilesandtest_compile_cargo_dependencies_invalid_cargo_tomlwithinin-cli/src/cargo_linker.rs.💡 Why:
Using
unwrap()can cause tests to hard crash when dealing with standard library I/O, giving less helpful stack traces or abrupt exits. By correctly setting the test signatures to returnstd::io::Result<()>and using?, failures are properly bubbled up natively via the test framework, making it safer, more readable, and idiomatically aligned with standard Rust testing practices.✅ Verification:
Ran local module tests via
cargo test cargo_linkerand full test suite viaIN_TEST_SKIP_SWIFT=1 ./install.sh && ~/.local/bin/in test. Verified no new warnings/errors withcargo clippy. Formatting is verified withcargo fmt.✨ Result:
Test functions now safely handle errors natively without unsafe
unwrapcalls.PR created automatically by Jules for task 9621440658014606791 started by @undivisible
Note
Low Risk
Test-only refactor with no production or runtime behavior changes.
Overview
Refactors two
cargo_linkerunit tests so setup I/O usesstd::io::Result<()>and?instead ofunwrap()onfs::create_dir_allandfs::write.test_compile_cargo_dependencies_finds_and_compilesandtest_compile_cargo_dependencies_invalid_cargo_tomlnow end withOk(()); behavior under test is unchanged.test_compile_cargo_dependencies_no_cargo_tomlis untouched.This is test-only cleanup—no production code changes.
Reviewed by Cursor Bugbot for commit 9d61e9b. Configure here.