-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
I'd be curious to hear thoughts from you guys on adding a mocking framework like mockall for PAC-generation?
Basically, I'd like to be able to rp-pac { version = "0.1.0", features = ["mocking"] }
as a dev-dep, and have something like this in the generation (for example):
#[cfg(all(test, feature = "mocking"))]
use mockall:automock;
...
// in fieldset.rs
...
#[cfg_attr(all(test, feature = "mockall", automock))]
pub struct #name (pub #ty);
#[cfg_attr(all(test, feature = "mockall", automock))]
impl #name {
#items
}
...
Then, in my code I could use:
#[double]
use pac::PWM as PWM;
Which would automatically expand PWM
to MockPWM
when I'm in test
-- this would let me mock registers etc. so that I can more easily test that the registers end up with the correct values (logic-wise, at least) in drivers without needing to involve a board.
Concrete example is working on this PR where via mocks I could manually step through the PWM counter and verify that the correct div/top/compares/etc. are set for each step in a test.
Thoughts?
crabdancing and chmousset
Metadata
Metadata
Assignees
Labels
No labels