Skip to content

Commit

Permalink
Use ctest
Browse files Browse the repository at this point in the history
  • Loading branch information
gen740 committed Jan 13, 2024
1 parent b8949ff commit ca0ce9f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 54 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@ jobs:
brew install ninja
continue-on-error: true

- name: Cmake and Compile
- name: Build Debug
run: |
cmake -B build -S . -DARGO_TESTS_ENABLE=true -GNinja
cmake --build build
cmake -B build_debug -S . -DARGO_TESTS_ENABLE=true -GNinja -DCMAKE_BUILD_TYPE=Debug
cmake --build build_debug
env:
CC: /usr/local/opt/llvm/bin/clang
CXX: /usr/local/opt/llvm/bin/clang++
LDFLAGS: -L/usr/local/opt/llvm/lib -L/usr/local/opt/llvm/lib/c++ -Wl,-rpath,/usr/local/opt/llvm/lib/c++
CPPFLAGS: -I/usr/local/opt/llvm/include

- name: Build Release
run: |
cmake -B build_release -S . -DARGO_TESTS_ENABLE=true -GNinja -DCMAKE_BUILD_TYPE=Release
cmake --build build_release
env:
CC: /usr/local/opt/llvm/bin/clang
CXX: /usr/local/opt/llvm/bin/clang++
Expand All @@ -48,17 +58,17 @@ jobs:

- name: Test Release
run: |
./build/test-argo-release
cmake --build build_release --target test
- name: Test Debug with codecov
run: |
LLVM_PROFILE_FILE=./build/test-argo-debug.profraw ./build/test-argo-debug
/usr/local/opt/llvm/bin/llvm-profdata merge -sparse ./build/test-argo-debug.profraw -o ./build/coverage.profdata
/usr/local/opt/llvm/bin/llvm-cov show ./build/test-argo-debug -instr-profile=./build/coverage.profdata -ignore-filename-regex="tests*" -ignore-filename-regex="Argo/ArgoExceptions.cc" > ./build/coverage.txt
LLVM_PROFILE_FILE=./build_debug/test-argo.profraw ./build_debug/test-argo
/usr/local/opt/llvm/bin/llvm-profdata merge -sparse ./build_debug/test-argo.profraw -o ./build_debug/coverage.profdata
/usr/local/opt/llvm/bin/llvm-cov show ./build_debug/test-argo -instr-profile=./build_debug/coverage.profdata -ignore-filename-regex="tests*" -ignore-filename-regex="Argo/ArgoExceptions.cc" > ./build_debug/coverage.txt
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
files: ./build/coverage.txt
files: ./build_debug/coverage.txt
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
22 changes: 16 additions & 6 deletions .github/workflows/test-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,30 @@ jobs:
wget https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip
yes | sudo unzip ninja-linux.zip -d /usr/local/bin
- name: Cmake and Compile
- name: Build Debug
run: |
cmake -B build -S . -DARGO_TESTS_ENABLE=true -GNinja
cmake --build build
cmake -B build_debug -S . -DARGO_TESTS_ENABLE=true -GNinja -DCMAKE_BUILD_TYPE=Debug
cmake --build build_debug
env:
CC: /usr/bin/clang-17
CXX: /usr/bin/clang++-17
LDFLAGS: -L/usr/lib/llvm-17/lib
CPPFLAGS: -stdlib=libc++

- name: Test Debug
- name: Build Release
run: |
./build/test-argo-debug
cmake -B build_release -S . -DARGO_TESTS_ENABLE=true -GNinja -DCMAKE_BUILD_TYPE=Release
cmake --build build_release
env:
CC: /usr/bin/clang-17
CXX: /usr/bin/clang++-17
LDFLAGS: -L/usr/lib/llvm-17/lib
CPPFLAGS: -stdlib=libc++

- name: Test Release
run: |
./build/test-argo-release
cmake --build build_release --target test
- name: Test Debug
run: |
cmake --build build_debug --target test
1 change: 1 addition & 0 deletions Argo/StdModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ using ::std::optional;

// expected
using ::std::expected;
using ::std::unexpected;

// NOLINTEND(bugprone-reserved-identifier)

Expand Down
56 changes: 17 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
# ############################### TESTS ######################################
if(${ARGO_TESTS_ENABLE})
# Reset all optimization flags
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_DEBUG "")

include(FetchContent)
FetchContent_Declare(
googletest
Expand All @@ -59,31 +56,23 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})
file(GLOB ARGO_TEST_SOURCES ${CMAKE_CURRENT_LIST_DIR}/tests/*.cc)

# ############################## DEBUG TARGET ##############################
add_executable(test-argo-debug ${ARGO_TEST_SOURCES})
target_link_libraries(
test-argo-debug PRIVATE GTest::gtest GTest::gtest_main GTest::gmock Argo)
set_target_properties(test-argo-debug PROPERTIES CXX_STANDARD 23)
target_compile_options(
test-argo-debug #
PRIVATE -Wno-writable-strings -DDEBUG_BUILD -O1 -g
-fprofile-instr-generate -fcoverage-mapping)
target_link_options(test-argo-debug PRIVATE -fprofile-instr-generate
-fcoverage-mapping)

# ############################## RELEASE TARGET ############################
add_executable(test-argo-release ${ARGO_TEST_SOURCES})
enable_testing()
add_executable(test-argo ${ARGO_TEST_SOURCES})
target_link_libraries(
test-argo-release PRIVATE GTest::gtest GTest::gtest_main GTest::gmock
Argo)
set_target_properties(test-argo-release PROPERTIES CXX_STANDARD 23)
target_compile_options(test-argo-release PRIVATE -Wno-writable-strings -O3)
test-argo PRIVATE GTest::gtest GTest::gtest_main GTest::gmock Argo)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
target_compile_options(
test-argo
PRIVATE -fprofile-instr-generate -fcoverage-mapping)
target_link_options(test-argo PRIVATE -fprofile-instr-generate -fcoverage-mapping)
endif()
set_target_properties(test-argo PROPERTIES CXX_STANDARD 23)
include(GoogleTest)
gtest_discover_tests(test-argo)
endif()

# ############################## BENCHMARKS #################################
if(${ARGO_BENCHMARKS_ENABLE})
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_DEBUG "")

find_package(benchmark REQUIRED)
file(GLOB ARGO_BENCHMARK_SOURCES ${CMAKE_CURRENT_LIST_DIR}/benchmarks/*.cc)

Expand All @@ -107,24 +96,13 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_LIST_DIR})

foreach(target ${ARGO_BENCHMARK_SOURCES})
get_filename_component(target_name ${target} NAME_WE)

# ############################# DEBUG TARGET #############################
set(debug_target_name "bench-${target_name}-debug")
add_executable(${debug_target_name} ${target})
target_link_libraries(${debug_target_name} benchmark::benchmark Argo
${CLI11_LIBRARY} ${argparse_LIBRARY})
set_target_properties(${debug_target_name} PROPERTIES CXX_STANDARD 23)
target_compile_options(
${debug_target_name} PRIVATE -Wno-writable-strings -fbracket-depth=1024
-DDEBUG_BUILD)
# ############################# RELEASE TARGET ###########################
set(release_target_name "bench-${target_name}-release")
add_executable(${release_target_name} ${target})
target_link_libraries(${release_target_name} benchmark::benchmark Argo
set(bench_target_name "bench-${target_name}")
add_executable(${bench_target_name} ${target})
target_link_libraries(${bench_target_name} benchmark::benchmark Argo
${CLI11_LIBRARY})
set_target_properties(${release_target_name} PROPERTIES CXX_STANDARD 23)
set_target_properties(${bench_target_name} PROPERTIES CXX_STANDARD 23)
target_compile_options(
${release_target_name} PRIVATE -Wno-writable-strings -O3
${bench_target_name} PRIVATE -Wno-writable-strings -O3
-fbracket-depth=1024)
endforeach()
endif()
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
test:
cmds:
- task: build
- ./build/test-argo-release
- cmake --build build --target test
silent: true
report:
cmds:
Expand Down

0 comments on commit ca0ce9f

Please sign in to comment.