Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions .github/workflows/cmake/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ inputs:
cmake_preset:
required: true
type: string
extra_cmake_args:
extra_cmake_build_args:
required: false
type: string
default: ''
extra_cmake_configure_args:
required: false
type: string
default: ''
extra_ctest_args:
required: false
type: string
default: ''
Expand All @@ -12,14 +20,14 @@ runs:
using: composite
steps:
- name: Configure CMake
run: cmake --preset ${{ inputs.cmake_preset }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev ${{ inputs.extra_cmake_args }}
shell: bash
run: cmake --preset ${{ inputs.cmake_preset }} ${{ inputs.extra_cmake_configure_args }} -DCI_TESTING:BOOL=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -Werror=dev
shell: ${{ env.RUNNER_OS == 'Windows' && 'pwsh' || 'bash' }}

- name: Build (with preset)
run: cmake --build --preset ${{ inputs.cmake_preset }}
shell: bash
run: cmake --build --preset ${{ inputs.cmake_preset }} ${{ inputs.extra_cmake_build_args }}
shell: ${{ env.RUNNER_OS == 'Windows' && 'pwsh' || 'bash' }}

- name: Test (with preset)
run: ctest --preset ${{ inputs.cmake_preset }} --output-on-failure --no-compress-output
shell: pwsh
run: ctest --preset ${{ inputs.cmake_preset }} ${{ inputs.extra_ctest_args }} --output-on-failure --no-compress-output
shell: ${{ env.RUNNER_OS == 'Windows' && 'pwsh' || 'bash' }}

7 changes: 4 additions & 3 deletions .github/workflows/compilers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
uses: ./.github/workflows/cmake
with:
cmake_preset: clang-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
extra_cmake_args: '-DCMAKE_CXX_FLAGS="-isysroot \"$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\""'
extra_cmake_configure_args: '-DCMAKE_CXX_FLAGS="-isysroot \"$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk\""'

VisualStudio:
strategy:
Expand All @@ -94,6 +94,7 @@ jobs:
uses: ./.github/workflows/cmake
with:
cmake_preset: msvc-${{ matrix.cxx_version }}-${{ matrix.build_type == 'Debug' && 'debug' || 'release' }}
extra_cmake_args: ${{ matrix.extra_args }}
shell: pwsh
extra_cmake_configure_args: ${{ matrix.extra_args }}
extra_cmake_build_args: --config ${{ matrix.build_type }}
extra_ctest_args: -C ${{ matrix.build_type }}

31 changes: 12 additions & 19 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,29 +199,22 @@ target_include_directories(gsl_tests_config SYSTEM INTERFACE
googletest/googletest/include
)

add_executable(gsl_tests
algorithm_tests.cpp
assertion_tests.cpp
at_tests.cpp
byte_tests.cpp
constexpr_notnull_tests.cpp
notnull_tests.cpp
owner_tests.cpp
pointers_tests.cpp
span_compatibility_tests.cpp
span_ext_tests.cpp
span_tests.cpp
strict_notnull_tests.cpp

utils_tests.cpp
)
# Individually build and register each test source (except no_exception_ensure_tests.cpp)
Comment thread
carsonRadtke marked this conversation as resolved.
# no_exception_ensure_tests.cpp is built separately with exceptions disabled
file(GLOB GSL_TEST_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
list(FILTER GSL_TEST_SOURCES EXCLUDE REGEX "no_exception_ensure_tests\\.cpp$")

target_link_libraries(gsl_tests
foreach(src IN LISTS GSL_TEST_SOURCES)
get_filename_component(test_name "${src}" NAME_WE)
add_executable(${test_name} ${src})
target_link_libraries(${test_name}
Microsoft.GSL::GSL
gsl_tests_config
${GTestMain_LIBRARIES}
)
add_test(gsl_tests gsl_tests)
)
add_test(NAME ${test_name} COMMAND ${test_name})
set_target_properties(${test_name} PROPERTIES FOLDER "tests")
endforeach()

# No exception tests

Expand Down