microsoft / microsoft/injectorppforrust
Is it possible to have more detailed error messages when a mock fails?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 404
- Forks
- 19
- Avg merge
- 23h 57m
- Merged PRs (30d)
- 1
Description
Hi,
When an injector fails within my unit tests, I receive:
thread 'linux_util::namespace::mount::tests::mount_happy' panicked at src/linux_util/namespace/mount.rs:228:27:
Fake function called with unexpected arguments
stack backtrace:
0: __rustc::rust_begin_unwind
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
1: core::panicking::panic_fmt
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
2: nucleus::linux_util::namespace::mount::tests::mount_happy::fake
at /home/fatih/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/injectorpp-0.4.0/src/interface/macros.rs:326:18
3: nucleus::linux_util::namespace::mount::mount
at ./src/linux_util/namespace/mount.rs:76:9
4: nucleus::linux_util::namespace::mount::tests::mount_happy
at ./src/linux_util/namespace/mount.rs:238:22
5: nucleus::linux_util::namespace::mount::tests::mount_happy::{{closure}}
at ./src/linux_util/namespace/mount.rs:167:21
6: core::ops::function::FnOnce::call_once
at /home/fatih/.rustup/toolchains/stable-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:253:5
7: core::ops::function::FnOnce::call_once
at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/ops/function.rs:253:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test linux_util::namespace::mount::tests::mount_happy ... FAILED
failures:
without any reasoning how the arguments does not match with the expected arguments by InjectorPP. I tried to execute this with RUST_BACKTRACE=full as well, but it just provides some more steps in the stacktrace, not the actual reason of why the injector failed.
Is there a way to make the error message explicit that where exactly the fake function fails to capture the actual request?
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
Reproduce the failure from the reported mount test and inspect injectorpp-0.4.0/src/interface/macros.rs around the fake function at line 326. Trace how expected and received arguments are handled when the mock rejects a call. Done means the failure explains which argument mismatch caused the fake function to reject the request.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100