Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OSX CI tests #319

Merged
merged 3 commits into from
Aug 27, 2023
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
44 changes: 44 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: CI OSX/AppleClang

on: [push, pull_request]

permissions:
contents: read

jobs:
build:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
build_type: [Debug]
cxx_std: [17, 20, 23]

steps:
- uses: actions/checkout@v3

- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure
working-directory: ${{runner.workspace}}/build
run: |
cmake -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \
-DENABLE_TESTING=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DOVERRIDE_CXX_STANDARD_FOR_TESTS=${{matrix.cxx_std}} \
-DENABLE_SANITIZERS_IN_TESTS=ON \
$GITHUB_WORKSPACE

- name: Build
working-directory: ${{runner.workspace}}/build
run: |
threads=`sysctl -n hw.logicalcpu`
cmake --build . --config ${{matrix.build_type}} --parallel $threads

- name: Test
working-directory: ${{runner.workspace}}/build
run: ctest -C ${{matrix.build_type}}
env:
CTEST_OUTPUT_ON_FAILURE: True
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# ARCH_INDEPENDENT option at write_basic_package_version_file requires 3.14 version of CMake.
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.14...3.26)

project(FakeIt VERSION 2.4.0 LANGUAGES CXX)

option(ENABLE_TESTING "Enable build of tests." OFF)
option(OVERRIDE_CXX_STANDARD_FOR_TESTS "Override the C++ standard used for building tests." "")
set(OVERRIDE_CXX_STANDARD_FOR_TESTS "" CACHE STRING "Override the C++ standard used for building tests.")
option(ENABLE_SANITIZERS_IN_TESTS "Enable address / undefined sanitizers in tests." OFF)
option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang." OFF)

Expand All @@ -15,6 +15,7 @@ add_subdirectory(include)
add_subdirectory(config)

if(ENABLE_TESTING)
enable_testing()
# Directory containing test targets of FakeIt.
add_subdirectory(tests)
endif()
Expand Down
4 changes: 3 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ target_link_libraries(FakeIt_tests PRIVATE
)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
target_compile_options(FakeIt_tests PRIVATE -Wall -Wextra -Wno-ignored-qualifiers -O0 -g3)
target_compile_options(FakeIt_tests PRIVATE -Wall -Wextra -Wno-ignored-qualifiers -Wno-uninitialized -O0 -g3)
elseif(MSVC)
target_compile_options(FakeIt_tests PRIVATE /W3 /sdl /Od)
endif()
Expand Down Expand Up @@ -65,3 +65,5 @@ if(ENABLE_COVERAGE)
message(SEND_ERROR "Code coverage requested but compiler is not compatible.")
endif()
endif()

add_test(NAME FakeIt_tests COMMAND FakeIt_tests)