Unit testing with cmake (#31)
* testing using ctest * emove old testing script * added github workflow CI * updated CI
This commit is contained in:
parent
799ecab03d
commit
4ea8f3ff12
|
@ -0,0 +1,37 @@
|
||||||
|
name: CMake
|
||||||
|
|
||||||
|
on:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
|
BUILD_TYPE: Release
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# The CMake configure and build commands are platform agnostic and should work equally
|
||||||
|
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||||
|
# cross-platform coverage.
|
||||||
|
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Configure CMake
|
||||||
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
|
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
# Build your program with the given configuration
|
||||||
|
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target make_tests
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: ${{github.workspace}}/build
|
||||||
|
# Execute tests defined by the CMake configuration.
|
||||||
|
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
||||||
|
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
|
||||||
|
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#!/bin/env bash
|
|
||||||
for i in $(ls -1 tests_*)
|
|
||||||
do
|
|
||||||
./$i;
|
|
||||||
ret=$?;
|
|
||||||
if [ $ret -ne 0 ];
|
|
||||||
then
|
|
||||||
exit $ret;
|
|
||||||
fi
|
|
||||||
done
|
|
|
@ -13,9 +13,9 @@ set(no08 PREFIX=no08 FIXMATH_NO_ROUNDING FIXMATH_OPTIMIZE_8BIT)
|
||||||
set(rn08 PREFIX=rn08 FIXMATH_NO_OVERFLOW FIXMATH_OPTIMIZE_8BIT)
|
set(rn08 PREFIX=rn08 FIXMATH_NO_OVERFLOW FIXMATH_OPTIMIZE_8BIT)
|
||||||
set(nn08 PREFIX=nn08 FIXMATH_NO_OVERFLOW FIXMATH_NO_ROUNDING FIXMATH_OPTIMIZE_8BIT)
|
set(nn08 PREFIX=nn08 FIXMATH_NO_OVERFLOW FIXMATH_NO_ROUNDING FIXMATH_OPTIMIZE_8BIT)
|
||||||
|
|
||||||
configure_file(tests/run_tests ${CMAKE_BINARY_DIR}/run_tests COPYONLY)
|
enable_testing()
|
||||||
|
|
||||||
add_custom_target(tests)
|
add_custom_target(make_tests)
|
||||||
|
|
||||||
function(create_variant name defs)
|
function(create_variant name defs)
|
||||||
add_library(libfixmath_${name} STATIC ${libfixmath-srcs})
|
add_library(libfixmath_${name} STATIC ${libfixmath-srcs})
|
||||||
|
@ -24,7 +24,8 @@ function(create_variant name defs)
|
||||||
target_link_libraries(tests_${name} PRIVATE libfixmath_${name} m)
|
target_link_libraries(tests_${name} PRIVATE libfixmath_${name} m)
|
||||||
target_include_directories(tests_${name} PRIVATE ${CMAKE_SOURCE_DIR})
|
target_include_directories(tests_${name} PRIVATE ${CMAKE_SOURCE_DIR})
|
||||||
target_compile_definitions(tests_${name} PRIVATE ${defs})
|
target_compile_definitions(tests_${name} PRIVATE ${defs})
|
||||||
add_dependencies(tests tests_${name})
|
add_dependencies(make_tests tests_${name})
|
||||||
|
add_test(NAME tests_${name} COMMAND tests_${name})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ extern unsigned stack_depth;
|
||||||
{ \
|
{ \
|
||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
fprintf(stdout, \
|
fprintf(stderr, \
|
||||||
"\033[31;1m FAILED:\033[22;39m%*s" #x \
|
"\033[31;1m FAILED:\033[22;39m%*s" #x \
|
||||||
" \033[0mat: " __FILE__ ":" STR2(__LINE__) " \n", \
|
" \033[0mat: " __FILE__ ":" STR2(__LINE__) " \n", \
|
||||||
stack_depth, ""); \
|
stack_depth, ""); \
|
||||||
|
@ -45,7 +45,7 @@ extern unsigned stack_depth;
|
||||||
{ \
|
{ \
|
||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
fprintf(stdout, \
|
fprintf(stderr, \
|
||||||
"\033[31;1m FAILED:\033[22;39m%*sASSERT_NEAR a: %f, b: " \
|
"\033[31;1m FAILED:\033[22;39m%*sASSERT_NEAR a: %f, b: " \
|
||||||
"%f, eps: %f\033[0m at: %s(), " __FILE__ \
|
"%f, eps: %f\033[0m at: %s(), " __FILE__ \
|
||||||
":" STR2(__LINE__) "\n", \
|
":" STR2(__LINE__) "\n", \
|
||||||
|
@ -63,7 +63,7 @@ extern unsigned stack_depth;
|
||||||
{ \
|
{ \
|
||||||
fflush(stdout); \
|
fflush(stdout); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
fprintf(stdout, \
|
fprintf(stderr, \
|
||||||
"\033[31;1m FAILED:\033[22;39m%*sASSERT_EQ a: %i, b: " \
|
"\033[31;1m FAILED:\033[22;39m%*sASSERT_EQ a: %i, b: " \
|
||||||
"%i\033[0m at: %s(), " __FILE__ ":" STR2(__LINE__) "\n", \
|
"%i\033[0m at: %s(), " __FILE__ ":" STR2(__LINE__) "\n", \
|
||||||
stack_depth, "", (a), (b), __func__); \
|
stack_depth, "", (a), (b), __func__); \
|
||||||
|
|
Loading…
Reference in New Issue