You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, thanks for your work here. This project has been a real time-saver.
When you have a large set of mocks, it can become quite difficult to debug a test failure.
Say for example that you have a test that mocks 4 GPIO pins, with a specific sequence of reads and writes. As it currently stands you might get a message like this;
---- context::tests::send_command stdout ----
thread 'context::tests::send_command' panicked at 'no expectation for pin::is_high call', /usr/local/cargo/git/checkouts/embedded-hal-mock-54d083840a293f52/d394c81/src/pin.rs:159:50
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Apart from the offending function call, this error message doesn't yield much useful information to track down where the failure has occurred. To improve these error messages I'd like to add a label so that; 'no expectation for pin::is_high call' becomes 'no expectation for pin::is_high call on pin my_label'
From the user facing API this might look something like;
// Not labelledletmut pin = PinMock::new(&expectations);// Labelledletmut pin = PinMock::new_with_label(&expectations,"my_label");
I'm happy to have a crack at implementing this, but I thought I get some input before going ahead with it.
interesting, seems like a reasonable addition to me! aside, have you tried RUST_BACKTRACE=1? i have found this (+ color-backtrace) to be very helpful for determining the call site.
Activity
ryankurte commentedon May 13, 2022
interesting, seems like a reasonable addition to me! aside, have you tried
RUST_BACKTRACE=1? i have found this (+ color-backtrace) to be very helpful for determining the call site.dbrgn commentedon May 13, 2022
@silvergasp looks useful, feel free to send a PR!