Add unit testing framework (#26948)

- Add a framework to build and execute unit tests for Marlin.
- Enable unit test execution as part of PR checks.

---------

Co-authored-by: Costas Basdekis <costas.basdekis@gmail.com>
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Jason Smith
2024-04-13 12:06:08 -07:00
committed by GitHub
parent cf7c86d581
commit d10861e478
21 changed files with 711 additions and 112 deletions

View File

@@ -15,13 +15,24 @@
[env:linux_native]
platform = native
framework =
build_flags = -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined
build_flags = ${common.build_flags} -D__PLAT_LINUX__ -std=gnu++17 -ggdb -g -lrt -lpthread -D__MARLIN_FIRMWARE__ -Wno-expansion-to-defined
build_src_flags = -Wall -IMarlin/src/HAL/LINUX/include
build_unflags = -Wall
lib_ldf_mode = off
lib_deps =
build_src_filter = ${common.default_src_filter} +<src/HAL/LINUX>
# Environment specifically for unit testing through the Makefile
# This is somewhat unorthodox, in that it uses the PlatformIO Unity testing framework,
# but actual targets are dynamically generated during the build. This seems to prevent
# Unity from being automatically included, so it is added here.
[env:linux_native_test]
extends = env:linux_native
extra_scripts = ${common.extra_scripts}
post:buildroot/share/PlatformIO/scripts/collect-code-tests.py
build_src_filter = ${env:linux_native.build_src_filter} +<tests>
lib_deps = throwtheswitch/Unity@^2.5.2
test_build_src = true
#
# Native Simulation
# Builds with a small subset of available features