Skip to content

Commit

Permalink
Bye bye Catch2, hello Google Test
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Jun 28, 2023
1 parent 20212e2 commit 381e310
Show file tree
Hide file tree
Showing 7 changed files with 532 additions and 18,532 deletions.
12 changes: 9 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: |
gcc --version
clang --version
clang-tidy --version
# TODO BEGIN https://github.com/OpenCyphal/docker_toolchains/issues/36
dpkg --add-architecture i386
apt-get update
apt-get install -y libgtest-dev libgtest-dev:i386
- run: >
cmake
-B ${{ github.workspace }}/build
Expand Down Expand Up @@ -60,6 +61,11 @@ jobs:
cxx-compiler: clang++
steps:
- uses: actions/checkout@v3
- run: |
# TODO BEGIN https://github.com/OpenCyphal/docker_toolchains/issues/36
dpkg --add-architecture i386
apt-get update
apt-get install -y libgtest-dev libgtest-dev:i386
- run: >
cmake
-B ${{ github.workspace }}/build
Expand Down
1 change: 1 addition & 0 deletions tests/.idea/dictionaries/pavel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 7 additions & 9 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ add_compile_options(
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wsign-promo")

include_directories(${library_dir})
include_directories(SYSTEM catch)

set(common_sources ${CMAKE_SOURCE_DIR}/main.cpp ${library_dir}/udpard.c)

function(gen_test name files compile_definitions compile_flags link_flags c_standard)
add_executable(${name} ${common_sources} ${files})
add_executable(${name} ${library_dir}/udpard.c ${files})
target_include_directories(${name} PUBLIC ${library_dir})
target_compile_definitions(${name} PUBLIC ${compile_definitions})
target_link_libraries(${name} pthread)
# We're not using find_package(GTest) because this method can only find the package for one specific architecture,
# which is not what we want. We build tests for AMD64 and x86 separately, which requires linking against different
# GTest libraries located in different directories. Instead of doing it the hard way via find_package separately
# per architecture, we just pass the library names directly and let the linker figure out where to find them.
target_link_libraries(${name} pthread gtest gtest_main)
set_target_properties(
${name}
PROPERTIES
Expand All @@ -67,10 +67,8 @@ endfunction()
function(gen_test_matrix name files compile_definitions compile_flags link_flags)
gen_test("${name}_x64_c99" "${files}" "${compile_definitions}" "${compile_flags} -m64" "-m64 ${link_flags}" "99")
gen_test("${name}_x32_c99" "${files}" "${compile_definitions}" "${compile_flags} -m32" "-m32 ${link_flags}" "99")
target_link_libraries("${name}_x32_c99" ${ADDITIONAL_LIBS_32})
gen_test("${name}_x64_c11" "${files}" "${compile_definitions}" "${compile_flags} -m64" "-m64 ${link_flags}" "11")
gen_test("${name}_x32_c11" "${files}" "${compile_definitions}" "${compile_flags} -m32" "-m32 ${link_flags}" "11")
target_link_libraries("${name}_x32_c11" ${ADDITIONAL_LIBS_32})
# Coverage is only available for GCC builds.
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
gen_test("${name}_cov"
Expand Down
Loading

0 comments on commit 381e310

Please sign in to comment.