rust-embedded-community / sh1106

SH1106 driver for use with embedded_hal and (optionally) embedded_graphics
Apache License 2.0
34 stars 36 forks source link

Running cargo test locally #33

Closed Angr1st closed 1 year ago

Angr1st commented 1 year ago

Hi @jamwaffles is there a way to run cargo test locally? I currently just get this error:

error[E0463]: can't find crate for `test`
   --> src/builder.rs:191:5
    |
190 |       #[test]
    |       ------- in this procedural macro expansion
191 | /     fn test_output_pin() {
192 | |         let p = NoOutputPin::new();
193 | |         let _d = SomeDriver { p };
194 | |
195 | |         assert!(true);
196 | |     }
    | |_____^ can't find crate
    |
    = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0463]: can't find crate for `test`

error: `#[panic_handler]` function required, but not found

For more information about this error, try `rustc --explain E0463`.
error: could not compile `sh1106` (lib test) due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
jamwaffles commented 1 year ago

Hey, thanks for asking! This error is weird but is due to some bit of the test harness not being supported in no_std. If you look in build.sh it hacks around this:

cargo test --lib --target x86_64-unknown-linux-gnu
cargo test --doc --target x86_64-unknown-linux-gnu

Alternatively, if you'd like to just run the entire script, you can:

rustup target add thumbv7em-none-eabi
TARGET=thumbv7em-none-eabi ./build.sh

You can change thumbv7em to thumbv6m or whatever arch your target IC uses.

Hope that helps!

Angr1st commented 1 year ago

Thank you that works like a charm 👍