diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000..48bd1cd --- /dev/null +++ b/.github/workflows/cmake.yml @@ -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 + + diff --git a/tests/run_tests b/tests/run_tests deleted file mode 100755 index 4b16a6e..0000000 --- a/tests/run_tests +++ /dev/null @@ -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 diff --git a/tests/tests.cmake b/tests/tests.cmake index 56aefe3..5f6c90b 100644 --- a/tests/tests.cmake +++ b/tests/tests.cmake @@ -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(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) 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_include_directories(tests_${name} PRIVATE ${CMAKE_SOURCE_DIR}) 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() diff --git a/tests/tests.h b/tests/tests.h index 6be58db..6bd8e4d 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -21,7 +21,7 @@ extern unsigned stack_depth; { \ fflush(stdout); \ fflush(stderr); \ - fprintf(stdout, \ + fprintf(stderr, \ "\033[31;1m FAILED:\033[22;39m%*s" #x \ " \033[0mat: " __FILE__ ":" STR2(__LINE__) " \n", \ stack_depth, ""); \ @@ -45,7 +45,7 @@ extern unsigned stack_depth; { \ fflush(stdout); \ fflush(stderr); \ - fprintf(stdout, \ + fprintf(stderr, \ "\033[31;1m FAILED:\033[22;39m%*sASSERT_NEAR a: %f, b: " \ "%f, eps: %f\033[0m at: %s(), " __FILE__ \ ":" STR2(__LINE__) "\n", \ @@ -63,7 +63,7 @@ extern unsigned stack_depth; { \ fflush(stdout); \ fflush(stderr); \ - fprintf(stdout, \ + fprintf(stderr, \ "\033[31;1m FAILED:\033[22;39m%*sASSERT_EQ a: %i, b: " \ "%i\033[0m at: %s(), " __FILE__ ":" STR2(__LINE__) "\n", \ stack_depth, "", (a), (b), __func__); \