Skip to content

Commit

Permalink
Ctest fix (#3)
Browse files Browse the repository at this point in the history
* add ls or dir command in ci to show the compiled tests binaries

* set cmake verbose ON

* add address sanitizer flags in CMake

* disable address sanitizer for windows

* temporarily disable asan for windows since I don't know yet how to make it work

* removed cmake test builds in the old test.yml file

* add architecture x86 support in CI

* remove architecture in ci matrix and fix gcc & clang cmake test build

* removed architecture in CI since it's not working

* fix ctests.yml for windows-clang and windows-gcc where previously it uses msvc compiler even though gcc and clang was specified in cmake variables
  • Loading branch information
mrdcvlsc authored May 31, 2024
1 parent e8bed57 commit 919130f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 65 deletions.
25 changes: 13 additions & 12 deletions .github/workflows/ctests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,33 @@ on:

jobs:
build-others:
name: ${{ matrix.platform.name }}-C++${{matrix.config.cxx_version}}
name: ${{ matrix.platform.name }} C++${{matrix.config.cxx_version}}
runs-on: ${{ matrix.platform.os }}

strategy:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019, os: windows-2019}
- { name: Windows VS2022, os: windows-2022}
- { name: Windows Clang, os: windows-2022, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++}
- { name: Windows GCC, os: windows-2022, flags: -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++}
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Linux, os: ubuntu-latest}
- { name: MacOS XCode, os: macos-latest}
- { name: Windows VS2019, os: windows-2019, flags: -DCMAKE_BUILD_TYPE=Debug }
- { name: Windows VS2022, os: windows-2022, flags: -DCMAKE_BUILD_TYPE=Debug }
- { name: Windows Clang, os: windows-latest, flags: -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Windows GCC, os: windows-latest, flags: -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ }
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Linux GCC, os: ubuntu-latest, flags: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ }
- { name: MacOS XCode, os: macos-latest, flags: -DCMAKE_BUILD_TYPE=Debug }
- { name: MacOS Clang, os: macos-latest, flags: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
config:
- { cxx_version: 20 }
- { cxx_version: 23 }

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: System Info
- name: Config
run: cmake -S tests -B tests ${{matrix.platform.flags}} -DCMAKE_CXX_STANDARD=${{matrix.config.cxx_version}}

- name: Build
run: cmake --build tests --config Debug -j2
run: cmake --build tests --config Debug

- name: Tests
run: ctest --test-dir tests
run: ctest --test-dir tests --build-config Debug --output-on-failure
48 changes: 0 additions & 48 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,8 @@ name: tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-others:
name: ${{ matrix.platform.name }}
runs-on: ${{ matrix.platform.os }}

strategy:
fail-fast: false
matrix:
platform:
# - { name: Linux Clang, os: ubuntu-latest, outpath: './tests/', flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: Windows VS2019, os: windows-2019, outpath: 'tests\Release\', fext: .exe, }
- { name: Windows VS2022, os: windows-2022, outpath: 'tests\Release\', fext: .exe, }
- { name: MacOS XCode, os: macos-latest, outpath: './tests/' }
# - { name: Linux GCC, os: ubuntu-latest, outpath: './tests/' }

steps:
- uses: actions/checkout@v3

- name: System Info
run: cmake cmake -S tests -B tests ${{matrix.platform.flags}}

- name: Build
run: cmake --build tests --config Release

- run: "${{matrix.platform.outpath}}addition${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}bitwise-and${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}bitwise-not${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}bitwise-or${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}bitwise-xor${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}boolean${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}constructor-initializer-list${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}constructor-integral${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}constructor-string-view${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}decrement${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}division${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}increment${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}modulo${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}multiplication${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}relational${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}shifts${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}subtraction${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}template${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}to-string-base10${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}to-string-base16${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}to-string-base2${{matrix.platform.fext}}"
- run: "${{matrix.platform.outpath}}to-string-base8${{matrix.platform.fext}}"

aarch64-gcc:

runs-on: ubuntu-latest
Expand Down
18 changes: 13 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
cmake_minimum_required(VERSION 3.16)
project(extended_precision_integers VERSION 1.0.0)

file(GLOB SOURCES "*.cpp")

set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# add_compile_definitions(USER_DEFINITION)

if(WIN32)
# disable windows asan for now since I don't know how to make it work
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /fsanitize=address")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fsanitize=address")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
endif()

enable_testing()

foreach(test_src_code ${SOURCES})
get_filename_component(test_exec_name ${test_src_code} NAME_WE)
add_executable(${test_exec_name} ${test_src_code})
# target_compile_features(${test_exec_name} PRIVATE cxx_std_11)
target_compile_options(${test_exec_name} PRIVATE -fsanitize=address)
target_link_options(${test_exec_name} PRIVATE -fsanitize=address)
add_test(
NAME ${test_exec_name}
COMMAND $<TARGET_FILE:${test_exec_name}>
)
endforeach(test_src_code ${SOURCES})
endforeach(test_src_code ${SOURCES})

0 comments on commit 919130f

Please sign in to comment.