support Unity testing

This commit is contained in:
proddy
2024-08-01 22:13:52 +02:00
parent 4ec5739b67
commit b38ec2f25e
16 changed files with 598 additions and 285 deletions

View File

@@ -30,7 +30,7 @@ build_flags =
-D ONEWIRE_CRC16=0
-D CONFIG_ETH_ENABLED
-D CONFIG_UART_ISR_IN_IRAM
-D CONFIG_ASYNC_TCP_STACK_SIZE=5120
-D CONFIG_ASYNC_TCP_STACK_SIZE=6144
-D CONFIG_ASYNC_TCP_QUEUE=32
-D CONFIG_ASYNC_TCP_TASK_PRIORITY=10
@@ -38,8 +38,7 @@ unbuild_flags =
${common.core_unbuild_flags}
[espressi32_base]
; 6.7.0 = Arduino v2.0.16 (based on IDF v4.4.7). See https://github.com/platformio/platform-espressif32/releases/tag/v6.7.0
platform = espressif32@6.7.0
platform = espressif32@6.8.0
framework = arduino
board_build.filesystem = littlefs
build_flags =
@@ -210,15 +209,30 @@ build_flags =
${common.build_flags}
build_unflags = ${common.unbuild_flags}
; to build and run: pio run -e native -t exec
;
; Building and testing natively, standalone without an ESP32.
; See https://docs.platformio.org/en/latest/platforms/native.html
;
; It will generate an executbale which when run will show the EMS-ESP Console where you can run tests using the `test` command.
;
; to build and run directly on linux: pio run -e native -t exec
;
; to build and run on Windows:
; - For the first time, install Msys2 (https://www.msys2.org/) and the GCC compiler with `run pacman -S mingw-w64-ucrt-x86_64-gcc`
; - Then, build with `pio run -e native` to create the program.exe file
; - run by calling the executable from the Mysys shell e.g. `C:/msys64/msys2_shell.cmd -defterm -here -no-start -ucrt64 -c /d/dev/proddy/EMS-ESP32/.pio/build/native/program.exe`
;
; The shell is needed to simulate the Winsock serial port.
; You can also integrate into Windows Terminal. See https://www.msys2.org/docs/terminals/
;
[env:native]
platform = native
extra_scripts = pre:scripts/rename_prog.py
build_flags =
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev.0\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-std=gnu++14 -Og -ggdb -D__linux__
-std=gnu++14 -Og -ggdb
build_type = debug
build_src_flags =
-Wall -Wextra -Werror
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
@@ -245,3 +259,47 @@ build_src_filter =
lib_compat_mode = off
lib_ldf_mode = off
lib_ignore = Module EMS-ESP-Modules
; unit tests
; pio run -e native-test -t exec
[env:native-test]
platform = native
test_build_src = true
build_flags =
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST -DUNITY_INCLUDE_CONFIG_H
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev.0\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-std=gnu++14 -Og -ggdb
-lgcov --coverage
build_type = debug
build_src_flags =
-Wall -Wextra -Werror
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
-I./lib_standalone
-I./lib/uuid-common/src
-I./lib/uuid-console/src
-I./lib/uuid-log/src
-I./lib/semver
-I./lib/PButton
-I./lib/ArduinoJson
-I./lib/espMqttClient/src
-I./lib/espMqttClient/src/Transport
-I./test/api
-I./test
build_src_filter =
+<*>
-<src/main.cpp>
+<../test>
+<../lib_standalone>
+<../lib/uuid-common>
+<../lib/uuid-console>
+<../lib/uuid-log>
+<../lib/semver>
+<../lib/PButton>
+<../lib/espMqttClient/src>
+<../lib/espMqttClient/src/Transport>
lib_ldf_mode = off
lib_deps = Unity
lib_ignore = Module EMS-ESP-Modules
test_testing_command =
${platformio.build_dir}/${this.__env__}/program