Compare commits

..

2 Commits

Author SHA1 Message Date
blueloveTH
10c53e0621 update cov 2025-12-02 22:04:42 +08:00
blueloveTH
ab513822b3 update cov 2025-12-02 21:37:47 +08:00
8 changed files with 34 additions and 6 deletions

View File

@ -64,6 +64,10 @@ jobs:
bash build_g.sh
bash run_tests.sh
rm -rf ./main
- name: Run Script Check
run: |
python scripts/check_pragma_once.py include
python scripts/check_undef.py src
- name: Unit Test with Coverage
run: bash run_tests.sh
- name: Upload coverage reports to Codecov

View File

@ -4,7 +4,7 @@ python prebuild.py
SRC=$(find src/ -name "*.c")
clang -std=c11 --coverage -O1 -Wfatal-errors -o main src2/main.c $SRC -Iinclude -DPK_ENABLE_OS=1 -DPK_ENABLE_PROFILER=1 -lm -ldl -DNDEBUG
clang -std=c11 --coverage -O1 -Wfatal-errors -o main src2/main.c $SRC -Iinclude -DPK_ENABLE_OS=1 -lm -ldl -DNDEBUG
python scripts/run_tests.py
@ -17,8 +17,17 @@ rm -rf .coverage
mkdir .coverage
UNITS=$(find ./ -name "*.gcno")
llvm-cov-15 gcov ${UNITS} -r -s include/ -r -s src/ >> .coverage/coverage.txt
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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -6,6 +6,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#else
#include <dlfcn.h>

View File

@ -5,6 +5,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <conio.h>
#undef WIN32_LEAN_AND_MEAN
#elif PY_SYS_PLATFORM == 3 || PY_SYS_PLATFORM == 5