-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a NoDetails
variant for MockError
#94
base: main
Are you sure you want to change the base?
Conversation
This allows the creation of errors without any details and removes the dependency on `std` just for errors.
I'm not sure I understand the purpose of this change. Can you give an example of where this is useful? |
Is that a problem? Currently embedded-hal-mock does require std, but I don't see any downsides to having to enable std for tests. |
@newAM, it just removes the current dependency on the standard library when using errors in mocks. This dependency means it is not possible to run some tests on target (devices that can't use the standard library).
@dbrgn, the main problem is that it means tests cannot be run on target. Other than that it adds a bit of extra boilerplate as then we need to use |
Well, it's not just the While I'm aware that there's a bit of boilerplate necessary for projects, the alternative would be increasing complexity of this project for all developers and contributors, by not using |
I am sorry to keep asking, but can you further clarify this? Code would help, if you can share it. I am confused because:
To make the crate compile for embedded targets requires adding |
Hi @dbrgn and @newAM, sorry for the confusion with this, I think that I've not made it very clear when I'm talking about I'd first like to state that I appreciate this crate very much and the work done here so I hope the correct tone comes across in this message. I think that my original point is hard to explain, but I will try. However, I'd like to ask: why does this crate use Right now I have:
Most of the tests are in I know it doesn't matter because the result is the same; directly or indirectly through I hope I explained it a bit better this time, thanks. P.S. I would be interested in looking at making this crate |
I think the Right now I don't know what the implications of making this library |
Currently, in
no_std
projects it is required to include the std library to test with mocks that return errors, this is because the only supportedMockError
is one that takes astd::io::ErrorKind
. By adding this new variant that doesn't depend on the std library we can keep the projectno_std
even for testing.I am open to other names if
NoDetails
is not a good fit. It might be nice to have separate errors for each type of mock e.g.MockError::Adc(AdcError::InvalidData)
but the way in this PR requires fewer changes.Thanks.