[Solved] Missing references to loop()/setup() once more

I am sorry to have to join the queue of people getting this - may be my fault is different though.

I have some example and test sketches in separate subdirectories to my main project directory. To build one of these, I will uncomment the respective env lines in platformio.ini. Here is an example that is supposed to build a test program:

[env]
platform = espressif32
board = az-delivery-devkit-v4
framework = arduino
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
board_build.partitions = default.csv
debug_tool = esp-prog
debug_init_break = tbreak setup
lib_ldf_mode = deep+
lib_deps =
  AsyncTCP
  Ethernet=https://github.com/maxgerhardt/Ethernet.git

# ... lines removed ...

# ********************* Test sketch
[env:TestSketch]
build_src_filter = +<*> -<.git/> -<.svn/> +<./Test/> -<./examples/>

But when building this, I get the notorious undefined reference to loop()/setup() messages. The file ./Test/main.cpp has both, but never is mentioned in the compiler log.

So I assume despite the build_src_filter setting the Test directory is not considered at all.

./Test/main.cpp

That’s the root cause.

The Test-Folder is for unit tests, not for holding your project source files.
See the README inside this folder:

This directory is intended for PlatformIO Test Runner and project tests.

Unit Testing is a software testing method by which individual units of
source code, sets of one or more MCU program modules together with associated
control data, usage procedures, and operating procedures, are tested to
determine whether they are fit for use. Unit testing finds problems early
in the development cycle.

More information about PlatformIO Unit Testing:

Put your source files into ./src folder and your project should build fine.

I always thought the PlatformIO folder would be named “test” (lowercase “t”), not “Test” (uppercase)?

Anyway, putting the testing and example files into src would spoil the library code that resides in there, so I do not think that would be a real solution.

“Test” and “test” will be the same on a Windows machine.

But there’s another issue: The path must be relative to src_dir per build_src_filter — PlatformIO latest documentation

It should work if you move your code to mytests folder and use

build_src_filter = +<../mytests/>
1 Like

:+1: That sounds very plausible. I will try that tomorrow. Thank you!

That nailed it. it has to be ../something if something is a parallel directory to src

Thanks a lot! :wink: