From f5fd7967c11ee216aa1615771fff2b3d41f6c79f Mon Sep 17 00:00:00 2001 From: kirto Date: Thu, 19 Mar 2026 10:05:31 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20test:=20=E5=8A=A0=E5=85=A5ec=5Ft?= =?UTF-8?q?est=5Fconfig=E7=A1=AE=E4=BF=9D=E6=B5=8B=E8=AF=95=E9=83=BD?= =?UTF-8?q?=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/embed_claw/test/CMakeLists.txt | 29 +++++++++++++-------- components/embed_claw/test/README.md | 8 ++++++ components/embed_claw/test/ec_test_config.h | 21 +++++++++++++++ 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 components/embed_claw/test/ec_test_config.h diff --git a/components/embed_claw/test/CMakeLists.txt b/components/embed_claw/test/CMakeLists.txt index b030a04..2b9416e 100644 --- a/components/embed_claw/test/CMakeLists.txt +++ b/components/embed_claw/test/CMakeLists.txt @@ -15,16 +15,23 @@ idf_component_register( embed_claw ) -set(EC_TEST_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_config.h") -if(EXISTS "${EC_TEST_CONFIG_HEADER}") - target_compile_options(${COMPONENT_LIB} PRIVATE - "-include" - "${EC_TEST_CONFIG_HEADER}" - ) +set(EC_TEST_DEFAULT_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_test_config.h") +set(EC_TEST_LOCAL_CONFIG_HEADER "${CMAKE_CURRENT_LIST_DIR}/ec_config.h") - idf_component_get_property(embed_claw_lib embed_claw COMPONENT_LIB) - target_compile_options(${embed_claw_lib} PRIVATE - "-include" - "${EC_TEST_CONFIG_HEADER}" - ) +if(NOT EXISTS "${EC_TEST_DEFAULT_CONFIG_HEADER}") + message(FATAL_ERROR "Missing tracked test config header: ${EC_TEST_DEFAULT_CONFIG_HEADER}") endif() + +idf_component_get_property(embed_claw_lib embed_claw COMPONENT_LIB) + +foreach(test_target ${COMPONENT_LIB} ${embed_claw_lib}) + if(EXISTS "${EC_TEST_LOCAL_CONFIG_HEADER}") + target_compile_options(${test_target} PRIVATE + "SHELL:-include ${EC_TEST_LOCAL_CONFIG_HEADER}" + ) + endif() + + target_compile_options(${test_target} PRIVATE + "SHELL:-include ${EC_TEST_DEFAULT_CONFIG_HEADER}" + ) +endforeach() diff --git a/components/embed_claw/test/README.md b/components/embed_claw/test/README.md index dfbc82f..b8fe586 100644 --- a/components/embed_claw/test/README.md +++ b/components/embed_claw/test/README.md @@ -124,6 +124,7 @@ ```text components/embed_claw/test/ ├── CMakeLists.txt +├── ec_test_config.h ├── partitions.csv ├── README.md ├── sdkconfig.defaults @@ -208,6 +209,13 @@ components/embed_claw/test/ 需要注意: +- `ec_test_config.h` + - 仓库内可提交的测试默认配置 + - 供 CI 和干净 checkout 的 `unit-test-app` 构建直接使用 + - 当前会提供最小 QQ dummy 配置,保证 QQ 相关测试编译路径始终可用 +- `ec_config.h` + - 本地私有、可选覆盖,默认不提交 + - 如果存在,会先于 `ec_test_config.h` 注入;`ec_test_config.h` 只补齐未定义的测试宏 - `sdkconfig.defaults` - 保留测试镜像自己的关键配置,当前显式关闭了 `PSRAM`,避免 `unit-test-app` 在 heap poisoning 下把临时分配落到 PSRAM,导致无关的堆损坏噪声 - `partitions.csv` diff --git a/components/embed_claw/test/ec_test_config.h b/components/embed_claw/test/ec_test_config.h new file mode 100644 index 0000000..9078f6e --- /dev/null +++ b/components/embed_claw/test/ec_test_config.h @@ -0,0 +1,21 @@ +#ifndef __EC_TEST_CONFIG_H__ +#define __EC_TEST_CONFIG_H__ + +/* + * Tracked test defaults for CI and clean checkouts. + * Local overrides can be placed in components/embed_claw/test/ec_config.h. + */ + +#ifndef EC_QQ_ENABLE +#define EC_QQ_ENABLE 1 +#endif + +#ifndef EC_QQ_APP_ID +#define EC_QQ_APP_ID "test-app-id" +#endif + +#ifndef EC_QQ_CLIENT_SECRET +#define EC_QQ_CLIENT_SECRET "test-client-secret" +#endif + +#endif // __EC_TEST_CONFIG_H__