PlatformIO Community

Test_build_src = true has no effect (anymore)

Hi, I’m a big fan of PlatformIO especially because it worked out of the box, when I tried it the first time.
That was like 8 month ago. I work with ESP32-S2, Arduino framework and I have independent code that I want to test with unity on windows (so I can debug comfortably)

This test I compile for platform = windows_x86 with test_build_src = true (I also tried test_build_src = yes). This is supposed to add all the cpp files in the test directory and complete my test. It used to work but now after a break of 5 month (and probably an update), it doesn’t compile the files int the test folder anymore. And I get a linkage error:

undefined reference to WinMain@16

It is the expected consequence when the test files are omitted by the compiler.

Can anybody tell me, why the compiler is ignoring the test folder?

config file:

platform = windows_x86
build_flags =
    -I include/utils
    -I include/Extensions
test_build_src = true
build_src_filter =
lib_deps =

Can you post the file structure of your project? (tree <your projectdirectroy>)

Thank you for the answer!
The digest of my tree is below. main.should.cpp contains the test main(). main.cpp contains the regular main but is removed from the compilation via the configuration.

│   .gitignore
│   platformio.ini
│   workspace.code-workspace
│   ├───driver
│   │       Driver_AdcPin.hpp
│   │       Driver_Spi.hpp
│   │       Driver_TickTime.hpp
│   │       Driver_Time.hpp       
│   ├───EVSE
│   │       ChargingHsm.hpp
│   │       CpModeHsm.hpp
│   │       WifiConnection.hpp
│   │       
│   └───win
│           WProgram.h
│   │   main.cpp
│   │   
│   ├───arduino
│   │       Driver_AdcPin_Arduino.cpp
│   │       Driver_Spi_Arduino.cpp
│   │       Driver_TickTime_Arduino.cpp
│   │       Driver_Trace_Arduino.cpp
│   │       
│   ├───EVSE
│   │       CpModeHsm.cpp
│   │       
│   │       
│   └───win
│           Driver_Spi_Win.cpp
│           Driver_Time_win.cpp
│           Driver_Trace_cmd_win.cpp

This folder structure is not valid, PlatformIO requires you to put the code files for each test unit in a new directory starting with test_. This is documented in point 3.

Also see official example