In my Arduino project the lib folder includes 23 sub-folders. Everything builds fine to create the binary for Arduino. When I try to compile for the Unity test environment the folder MqttMessageHandler is not included (#include “MqttMessageHandler.h” no such file or directory). I can force the header file to be included by giving a full relative path. The dependency graph does not include MqttMessageHandler so it isn’t compiled and I get a bunch of linker errors.
The folder structure under lib for each of the classes is:
Class
+-src
+-Class.cpp
+-include
+-Class.h
This applies to all the classes that work properly and the one that doesn’t. I’ve even checked the linux file system for trailing spaces in folder names.
I’ve tried moving the .h and .cpp files into the root class folder with no change.
I’ve moved them to the root of a working class which only served to break that class - perhaps won’t scan into sub-folders if there are files in the root - and didn’t make MqttMessageHandler work anyway.
Here’s the platformio.ini:
[platformio]
default_envs = megaatmega2560
[env]
build_flags =
!echo '-D VERSION=\"'$(date +"%%Y%%m%%d_%%H%%M%%S")'\"'
[env:megaatmega2560]
board = megaatmega2560
framework = arduino
lib_deps =
DallasTemperature
PubSubClient
arduino-libraries/Ethernet@2.0.2
platform = atmelavr
monitor_speed = 38400
build_flags =
${env.build_flags}
[env:test]
platform = native
build_type = test
test_framework = unity
test_ignore =
ignore/*
build_flags =
${env.build_flags}
-D TEST_ENV
The source file that won’t include the header is the test file for MqttMessageHandler. It is in test/test_MqttMessageHandler. The source file includes 9 of the other classes without any problem.
The MqttMessageHandler class is one of the last ones created if that could have any bearing on the problem.