Expand test coverage for error-handling macros and error pool
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m42s
All checks were successful
libakerror CI Build / cmake_build (push) Successful in 2m42s
Add 11 CTest programs and a shared test helper covering gaps left by the original four tests (which only exercised FAIL/CATCH/HANDLE and CLEANUP): - err_capture.h: capturing akerr_log_method + NDEBUG-proof AKERR_CHECK so tests can assert on message/status/stacktrace content, not just exit codes - err_success: clean nested return does not break/handle/leak - err_pool_refcount: 100k raise->catch->handle cycles leak 0 pool slots - err_handle_default / err_handle_group / err_handle_dispatch: handler routing - err_pass / err_ignore / err_swallow: PASS, IGNORE, FINISH(e,false) - err_break_variants: FAIL_*_BREAK and FAIL_*_RETURN - err_errno: system errno name lookup + "Unknown Error" boundary - err_custom_handler: override the unhandled-error hook, assert non-fatally Register tests via a foreach loop in CMakeLists.txt. Ignore build/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,25 +44,43 @@ target_compile_definitions(akerror
|
||||
PUBLIC AKERR_USE_STDLIB=${AKERR_USE_STDLIB}
|
||||
)
|
||||
|
||||
add_executable(test_err_catch tests/err_catch.c)
|
||||
add_executable(test_err_cleanup tests/err_cleanup.c)
|
||||
add_executable(test_err_trace tests/err_trace.c)
|
||||
add_executable(test_err_improper_closure tests/err_improper_closure.c)
|
||||
add_test(NAME err_catch COMMAND test_err_catch)
|
||||
add_test(NAME err_cleanup COMMAND test_err_cleanup)
|
||||
add_test(NAME err_trace COMMAND test_err_trace)
|
||||
add_test(NAME err_improper_closure COMMAND test_err_improper_closure)
|
||||
|
||||
set_tests_properties(
|
||||
err_trace
|
||||
err_improper_closure
|
||||
PROPERTIES WILL_FAIL TRUE
|
||||
# Each test is one source file in tests/ built into test_<name> and registered
|
||||
# as CTest <name>. Tests expected to abort (unhandled error / contract
|
||||
# violation) go in AKERR_WILL_FAIL_TESTS; all others must exit 0.
|
||||
set(AKERR_TESTS
|
||||
err_catch
|
||||
err_cleanup
|
||||
err_trace
|
||||
err_improper_closure
|
||||
err_success
|
||||
err_pool_refcount
|
||||
err_handle_default
|
||||
err_handle_group
|
||||
err_handle_dispatch
|
||||
err_pass
|
||||
err_ignore
|
||||
err_swallow
|
||||
err_errno
|
||||
err_break_variants
|
||||
err_custom_handler
|
||||
)
|
||||
|
||||
target_link_libraries(test_err_catch PRIVATE akerror)
|
||||
target_link_libraries(test_err_cleanup PRIVATE akerror)
|
||||
target_link_libraries(test_err_trace PRIVATE akerror)
|
||||
target_link_libraries(test_err_improper_closure PRIVATE akerror)
|
||||
set(AKERR_WILL_FAIL_TESTS
|
||||
err_trace
|
||||
err_improper_closure
|
||||
)
|
||||
|
||||
foreach(_test IN LISTS AKERR_TESTS)
|
||||
add_executable(test_${_test} tests/${_test}.c)
|
||||
target_include_directories(test_${_test} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests)
|
||||
target_link_libraries(test_${_test} PRIVATE akerror)
|
||||
add_test(NAME ${_test} COMMAND test_${_test})
|
||||
endforeach()
|
||||
|
||||
set_tests_properties(
|
||||
${AKERR_WILL_FAIL_TESTS}
|
||||
PROPERTIES WILL_FAIL TRUE
|
||||
)
|
||||
|
||||
set(main_lib_dest "lib/my_library-${MY_LIBRARY_VERSION}")
|
||||
install(TARGETS akerror
|
||||
|
||||
Reference in New Issue
Block a user