From 10c53e0621c95ba9aa255bbf4258ef6b0686ffbf Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Tue, 2 Dec 2025 22:04:42 +0800 Subject: [PATCH] update cov --- run_tests.sh | 18 +++++++++--------- scripts/check_undef.py | 7 +++++++ src/common/threads.c | 6 ++++++ src/debugger/dap.c | 7 ++++--- src/interpreter/ceval.c | 1 - src/interpreter/dll.c | 1 + src/modules/conio.c | 1 + 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 925378f0..6b2c46ef 100644 --- a/run_tests.sh +++ b/run_tests.sh @@ -16,18 +16,18 @@ fi rm -rf .coverage mkdir .coverage -# remove .gcno files if the 1st line contains "Source:src/debugger/" -find . -type f -name "*.gcno" | while read -r file; do - first_line=$(head -n 1 "$file") - if [[ "$first_line" == *"Source:src/debugger/"* ]]; then - echo "Deleting: $file" - rm -f "$file" - fi -done - UNITS=$(find ./ -name "*.gcno") llvm-cov-17 gcov ${UNITS} -r -s include/ -r -s src/ >> .coverage/coverage.txt mv *.gcov .coverage rm *.gcda rm *.gcno + +# remove .gcno files if the 1st line contains "Source:src/debugger/" +find .coverage/ -type f -name "*.gcov" | while read -r file; do + first_line=$(head -n 1 "$file") + if [[ "$first_line" == *"Source:src/debugger/"* ]]; then + echo "Removing: $file" + rm "$file" + fi +done diff --git a/scripts/check_undef.py b/scripts/check_undef.py index 9e275718..6d086275 100644 --- a/scripts/check_undef.py +++ b/scripts/check_undef.py @@ -1,5 +1,7 @@ import re +whitelist = {'K', 'equal', 'V', 'less', 'NAME'} + def check_define_undef_pairs(code): # 使用正则表达式匹配#define和#undef指令 define_pattern = re.compile(r'#define\s+(\w+)') @@ -9,6 +11,9 @@ def check_define_undef_pairs(code): defines = define_pattern.findall(code) undefs = undef_pattern.findall(code) + defines = [x for x in defines if x not in whitelist] + undefs = [x for x in undefs if x not in whitelist] + # 使用集合计算差集,找出不匹配的部分 define_set = set(defines) undef_set = set(undefs) @@ -21,11 +26,13 @@ def check_define_undef_pairs(code): print("mismatched #define") for define in unmatched_defines: print(f"- {define}") + exit(1) if unmatched_undefs: print("mismatched #undef") for undef in unmatched_undefs: print(f"- {undef}") + exit(1) # iterate over all the files in `path` directory diff --git a/src/common/threads.c b/src/common/threads.c index 33792b15..6e22543a 100644 --- a/src/common/threads.c +++ b/src/common/threads.c @@ -220,4 +220,10 @@ void c11_thrdpool__join(c11_thrdpool *pool) { c11_thrdpool_debug_log(-1, "All %d tasks completed, `sync_val` was reset.", num_tasks); } +#undef C11_THRDPOOL_DEBUG + +#ifdef c11_thrdpool_debug_log +#undef c11_thrdpool_debug_log +#endif + #endif // PK_ENABLE_THREADS \ No newline at end of file diff --git a/src/debugger/dap.c b/src/debugger/dap.c index 13026a88..d17ea30f 100644 --- a/src/debugger/dap.c +++ b/src/debugger/dap.c @@ -28,7 +28,8 @@ #define DECLARE_HANDLE_FN(name) void c11_dap_handle_##name(py_Ref arguments, c11_sbuf*); DAP_COMMAND_LIST(DECLARE_HANDLE_FN) -#undef DECLARE_ARG_FN +#undef DECLARE_HANDLE_FN + typedef void (*c11_dap_arg_parser_fn)(py_Ref, c11_sbuf*); @@ -43,6 +44,7 @@ static dap_command_entry dap_command_table[] = { }; #undef DAP_ENTRY +#undef DAP_COMMAND_LIST static struct c11_dap_server { int dap_next_seq; @@ -129,12 +131,11 @@ void c11_dap_handle_setBreakpoints(py_Ref arguments, c11_sbuf* buffer) { PK_FREE((void*)sourcename); } -inline static void c11_dap_build_ExceptionInfo(const char* exc_type, const char* exc_message, c11_sbuf* buffer) { +static void c11_dap_build_ExceptionInfo(const char* exc_type, const char* exc_message, c11_sbuf* buffer) { const char* safe_type = exc_type ? exc_type : "UnknownException"; const char* safe_message = exc_message ? exc_message : "No additional details available"; c11_sv type_sv = {.data = safe_type, .size = strlen(safe_type)}; - c11_sv message_sv = {.data = safe_message, .size = strlen(safe_message)}; c11_sbuf combined_buffer; c11_sbuf__ctor(&combined_buffer); diff --git a/src/interpreter/ceval.c b/src/interpreter/ceval.c index 5bddb613..0ef2c30c 100644 --- a/src/interpreter/ceval.c +++ b/src/interpreter/ceval.c @@ -1445,7 +1445,6 @@ bool pk_format_object(VM* self, py_Ref val, c11_sv spec) { return true; } -#undef CHECK_RETURN_FROM_EXCEPT_OR_FINALLY #undef DISPATCH #undef DISPATCH_JUMP #undef DISPATCH_JUMP_ABSOLUTE diff --git a/src/interpreter/dll.c b/src/interpreter/dll.c index 54f0297f..910e9778 100644 --- a/src/interpreter/dll.c +++ b/src/interpreter/dll.c @@ -6,6 +6,7 @@ #define WIN32_LEAN_AND_MEAN #include +#undef WIN32_LEAN_AND_MEAN #else #include diff --git a/src/modules/conio.c b/src/modules/conio.c index 78f543c0..df5e16c6 100644 --- a/src/modules/conio.c +++ b/src/modules/conio.c @@ -5,6 +5,7 @@ #define WIN32_LEAN_AND_MEAN #include #include +#undef WIN32_LEAN_AND_MEAN #elif PY_SYS_PLATFORM == 3 || PY_SYS_PLATFORM == 5