| ▲ | iconara 4 days ago | ||||||||||||||||||||||
The [page on testing][1] suggests this: > Where possible, and where it makes sense, you should try to test as much as possible on your host machine, not on the target device. When I have tried this I have encountered multiple problems, first that the Rust test framework requires std, making it convoluted writing test code – but when working around that using conditional compilation, I run into other things like the `esp-hal` depending on crates that won't compile on the host. What is the recommended way to test on the host? | |||||||||||||||||||||||
| ▲ | bigfishrunning 3 hours ago | parent | next [-] | ||||||||||||||||||||||
Especially for embedded work (but for regular software too!) I've bought into the "sans-io pattern" for a lot of the software i write anymore https://sans-io.readthedocs.io/how-to-sans-io.html Keeping all of the actual hardware/network/io interface code separate really makes writing unit tests and porting to different computers much simpler | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | officialchicken 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
I don't use the the builtin testing framework, or std, and I often explicitly use a no-heap crate. Check out Embassy and you'll be free to ignore pretty almost everything suggested here, especially when developing and testing. I create a separate [bin] for each test (I usually run out of flash to fit all the tests into a single binary), and a few lines of bash/python to make a test runner/reporter for all the flashing and running of tests. Sometimes I flash up to 50 times a day and haven't lost an MCU (AVR-Rust, ESP-Rust, STM-Rust) yet due to too many writes. | |||||||||||||||||||||||
| ▲ | devmor 3 hours ago | parent | prev [-] | ||||||||||||||||||||||
This is a constant issue for me in every facet of embedded development - with the sole exception of devices that can easily be tested in a qemu environment. I would also love to hear that the authors of this book suggest. | |||||||||||||||||||||||