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?
platform = windows_x86
test_build_src = true
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.cpp contains the regular main but is removed from the compilation via the configuration.
│ │ Driver_AdcPin.hpp
│ │ Driver_Spi.hpp
│ │ Driver_TickTime.hpp
│ │ Driver_Time.hpp
│ │ ChargingHsm.hpp
│ │ CpModeHsm.hpp
│ │ WifiConnection.hpp
│ │ main.cpp
│ │ Driver_AdcPin_Arduino.cpp
│ │ Driver_Spi_Arduino.cpp
│ │ Driver_TickTime_Arduino.cpp
│ │ Driver_Trace_Arduino.cpp
│ │ CpModeHsm.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
@maxgerhard: I would like to apologize sincerely for starting this post and causing troubles. Can it be deleted? I feel deeply ashamed for doing a basic/foolish mistake and for blaming PlatformIO for it:
I have realized that I forgot to call the Test command in the Advanced section.
I called Build instead and it always gave me the same issue.
As for the test structure: it doesn’t really need the test_* sub folders if there aren’t multiple test suites. But that is only a detail. (If you looking at this post as a solution, look also at the post above from maxgerhard pointing out the existing examples for tests.)
Again, please accept my apologies for not using PlatformIO correctly - problem solved / case closed