The behavior looks odd to me, though I am not sure is this a bug or a “by design”.
I’ve encountered it in my personal project, but for the illustration purposes I’ll use platformio-examples/unit-testing/calculator at develop · platformio/platformio-examples · GitHub as a basis.
So, say, I wish to use 3rd party lib in my project.
Thus I include the relevant ‘.h’ file and a dependency
pio run -e esp32 builds successfully
[image #2 - see below]
Now, the Adafruit ‘.h’ is only referenced in my project’s ‘/src’, and it is not referenced in my embedded tests (well I don’t intend to test it there), but weirdly the
pio test -e esp32 fails to execute from this point on. (Just to emphasize, the tests had run successfuly before I added the Adafruit to lib_deps.)
[image #3 - see below]
whereas the failure cause is
.pio/libdeps/esp32/Adafruit BMP280 Library/Adafruit_BMP280.h:26:10: fatal error: Adafruit_Sensor.h: No such file or directory
After some googling around the community and experimenting, I ended up with two possible workarounds, which make the tests successfull again:
[image #4 - see below]
- either add
lib_ldf_mode = deepto the env config (which is not really reccomended and increases a build time)
- or add
#include <Adafruit_BMP280.h>to every single test (even though I don’t need it there)
Both workardounds don’t really look like a “sustainable development” to me.
So am I doing anything wrong? Or is it a PIO bug? Or is it the Adafruit issue?
The latter statement I had added due to following observations:
- The problem reproduces with ‘Adafruit’ library, but doesn’t seem to happen with, say, ‘AccelStepper’.
- It is not directly related to
test-s subsystem: e.g. if the library is added to env lib_deps, while you don’t include .h into the /src/main.cpp, the
runfails to build similarily.
Sorry, due to a limitation of a forum board, had to attach other screenshots as the separate posts below