oxidecomputer / oxidecomputer/crucible
Update some tests to not return `Result<()>` and use unwrap() instead of `?`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 260
- Forks
- 34
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 8
Description
With tests that return Result<()>, a failure can result in a non specific message like this:
thread 'test::integration_test_region' panicked at 'assertion failed: `(left == right)`
left: `1`,
right: `0`: the test returned a termination value with a non-zero status code (1) which indicates a failure', /rustc/65c55bf931a55e6b1e5ed14ad8623814a7386424/library/test/src/lib.rs:195:5
That may be fine for a simple test that only does one thing, but many crucible tests do a bunch
of stuff, include calling out to places that can fail. If we change these tests to .unwrap() instead
of ? and don't return Resutl<()> from the test, we can get more meaningful errors, like this:
thread 'test::integration_test_region' panicked at 'called `Result::unwrap()` on an `Err` value: Block size mismatch', integration_tests/src/lib.rs:232:66
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in integration_tests/src/lib.rs, including the example location at line 232, and find tests that return Result<()> and propagate failures with ?. Replace the relevant test error propagation as described, then run the affected integration tests and confirm failures report the underlying error and location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100