diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f565ff..bca540b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ if(CONFIG_ZMK_JAVELIN_STENO) endforeach() endif() + # Override dir MUST come before javelin/ so our unit_test.h is found first + zephyr_include_directories(include/javelin_overrides) zephyr_include_directories(javelin) zephyr_include_directories(include) @@ -220,10 +222,8 @@ if(CONFIG_ZMK_JAVELIN_STENO) JAVELIN_BOARD_CONFIG= M_PI=3.14159265358979323846 ) - # Suppress test compilation: Javelin's TEST_BEGIN/TEST_END macros - # compile test bodies even without RUN_TESTS. Some tests reference - # RUN_TESTS-only APIs. Override macros via include to dead-code them. - zephyr_library_compile_options(-include ${CMAKE_CURRENT_LIST_DIR}/include/zmk_javelin_steno/suppress_tests.h) + # Test suppression handled by include/javelin_overrides/unit_test.h + # which shadows Javelin's unit_test.h via include path ordering. target_sources(app PRIVATE ${ZMK_BEHAVIOR_SRC} diff --git a/include/javelin_overrides/unit_test.h b/include/javelin_overrides/unit_test.h new file mode 100644 index 0000000..f9d8933 --- /dev/null +++ b/include/javelin_overrides/unit_test.h @@ -0,0 +1,22 @@ +// Override Javelin's unit_test.h to suppress test body compilation. +// When Javelin source files #include "unit_test.h", this file is found +// first (via include path ordering) and replaces the original. + +#pragma once +#include + +// TEST_BEGIN opens a never-instantiated template function body. +// Code between TEST_BEGIN and TEST_END is syntactically parsed but +// never compiled (dead template), avoiding errors from RUN_TESTS-only APIs. + +#define TEST_BEGIN__(text, file, line) \ + namespace DeadTest##line { \ + template \ + static void Dead() { + +#define TEST_END \ + } \ + } + +#define TEST_BEGIN_(desc, file, line) TEST_BEGIN__(desc, file, line) +#define TEST_BEGIN(desc) TEST_BEGIN_(desc, __FILE__, __LINE__)