PlatformIO Community

When running tests. Update.h: No such file or directory

I’m trying to add tests to existing project. Used instruction:

Processing * in esp32dev environment
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building & Uploading...
.pio/libdeps/esp32dev/ArduinoOTA/src/InternalStorageESP.cpp:24:10: fatal error: Update.h: No such file or directory

****************************************************************
* Looking for Update.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Update.h"
* Web  > https://registry.platformio.org/search?q=header:Update.h
*
****************************************************************

There is difference between environments for src and test ?

Thanks

Try adding lib_ldf_mode = chain+ in the platformio.ini.

Added lib_ldf_mode = chain+. The same error

Open a CLI. What’s the output of pio test -vvv?

Can’t attach logs here. Logs of pio test -vvv > pio_test_verbose.txt 2>&1.
Link to GDrive: https://drive.google.com/file/d/17zwdtjbtPOHV30w2bLHUUFeBu_a3KwJQ/view?usp=sharing

Hm that’s weird, the LDF mode is still set to chain (not chain+), and so the dependencies are not detected correctly.

LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 48 compatible libraries
Scanning dependencies...
Dependency Graph
|-- ArduinoBleOta @ 1.0.0+sha.8576882 (License: Unknown, URI: git+https://github.com/vovagorodok/ArduinoBleOta, Path: /home/tsiselsk/Projects/private/magic_chess_game/eboard/.pio/libdeps/esp32dev/ArduinoBleOta)
|   |-- ArduinoOTA @ 1.0.9 (License: Unknown, Path: /home/tsiselsk/Projects/private/magic_chess_game/eboard/.pio/libdeps/esp32dev/ArduinoOTA)

Does this happen with the latest core version? CLI + pio ugprade --dev to update.

Hm that’s weird, the LDF mode is still set to chain (not chain+), and so the dependencies are not detected correctly.

Now lib_ldf_mode = chain+ is removed from platformio.ini. Restore it?

Does this happen with the latest core version? CLI + pio ugprade --dev to update.

tsiselsk@tsiselsk-pc:~/Projects/private/magic_chess_game/eboard$ pio upgrade --dev
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 6.1.6a3
Release notes: https://docs.platformio.org/en/latest/history.html
Warning! Please restart IDE to affect PIO Home changes

Restarted IDE. Error still exist

Try lib_ldf_mode = deep+ instead. Does deep+ then appearp as the LDF mode in pio test -vvv?

With lib_ldf_mode = deep+ verbose logs: https://drive.google.com/file/d/1ASzz7IdOGWEcayzOOAw3Bz0EsRF-T58P/view?usp=sharing

Now:

|-- ArduinoBleOta @ 1.0.0+sha.8576882 (License: Unknown, URI: git+https://github.com/vovagorodok/ArduinoBleOta, Path: /home/tsiselsk/Projects/private/magic_chess_game/eboard/.pio/libdeps/esp32dev/ArduinoBleOta)
|   |-- ArduinoOTA @ 1.0.9 (License: Unknown, Path: /home/tsiselsk/Projects/private/magic_chess_game/eboard/.pio/libdeps/esp32dev/ArduinoOTA)
|   |   |-- Update @ 2.0.0 (License: Unknown, Path: /home/tsiselsk/.platformio/packages/framework-arduinoespressif32/libraries/Update)

Update dependency is visible, but linking error

Processing * in esp32dev environment
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building & Uploading...
/home/tsiselsk/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32dev/libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0x8): undefined reference to `setup()'
/home/tsiselsk/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32dev/libFrameworkArduino.a(main.cpp.o):(.literal._Z8loopTaskPv+0xc): undefined reference to `loop()'
/home/tsiselsk/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: .pio/build/esp32dev/libFrameworkArduino.a(main.cpp.o): in function `loopTask(void*)':
/home/tsiselsk/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:42: undefined reference to `setup()'
/home/tsiselsk/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld: /home/tsiselsk/.platformio/packages/framework-arduinoespressif32/cores/esp32/main.cpp:48: undefined reference to `loop()'
collect2: error: ld returned 1 exit status
*** [.pio/build/esp32dev/firmware.elf] Error 1
Uploading stage has failed, see errors above. Use `pio test -vvv` option to enable verbose output.
---------------------------------------------------------------- esp32dev:* [ERRORED] Took 13.72 seconds ----------------------------------------------------------------

================================================================================ SUMMARY ================================================================================
Environment    Test    Status    Duration
-------------  ------  --------  ------------
esp32dev       *       ERRORED   00:00:13.717
=============================================================== 1 test cases: 0 succeeded in 00:00:13.717 ===============================================================

ArduinoBleOta is public library created by me. Maybi there is issue

Yes, that looks way better now.

In the test file, you still have to have setup() and loop()

Also make sure your test file in a folder starting with test_ in the test/ folder, like the above example.

See docs.

Compilation success for:

#include <Arduino.h>
#include <unity.h>

void setup() {
    UNITY_BEGIN();
    UNITY_END();
}

void loop() {
}

Before was:

#include <unity.h>

void setUp(void) {
    // set stuff up here
}

void tearDown(void) {
    // clean stuff up here
}

int main( int argc, char **argv) {
    UNITY_BEGIN();
    UNITY_END();
}

What about lib_ldf_mode = deep+ it is required for decencies deep > 2? For src/ code it compiles without this mode (or deep+ i default?)

I’m not exactly sure why one mode would work in regular compilation and the other one unit testing.

Chain can also detect nested includes if the dependency is visible in the header file (docs).

I’m not exactly sure why one mode would work in regular compilation and the other one unit testing.

Hmm, maybe we should create issue in order to check/align it?

Yes, can you upload a minimal project that reproduces that problem to Issues · platformio/platformio-core · GitHub?

Hmm, strange. When new minimal project created. Error is available even for src.
Link to minimal project: GitHub - vovagorodok/deep_lib_issue

Still, create issue for that?

No that’s expected since you didn’t place an #include <ArduinoOTA.h> in src/main.cpp. Dependencies which you declare in platformio.ini but never include in your source code will not have their dependencies found properly.

You also placed a #include <ArduinoOTA.h> in the test cases souce code, yes?

Adding #include <ArduinoOTA.h> fixes error in src and test.

For src it looks ok, because for code adding wireless uploads is valid.
But for tests #include <ArduinoOTA.h> is not needed, because wireless upload possibility is not needed for testing.
It means that for test we should add #include <ArduinoOTA.h> only because compilation workaround.
Hmm, trying to find more glance solution