diff --git a/.github/workflows/test-mac.yml b/.github/workflows/test-mac.yml index e82d975..de5de3b 100644 --- a/.github/workflows/test-mac.yml +++ b/.github/workflows/test-mac.yml @@ -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++ @@ -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 }} diff --git a/.github/workflows/test-ubuntu.yml b/.github/workflows/test-ubuntu.yml index 7414ca6..bd6eb10 100644 --- a/.github/workflows/test-ubuntu.yml +++ b/.github/workflows/test-ubuntu.yml @@ -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 diff --git a/Argo/StdModule.cc b/Argo/StdModule.cc index 98cb72b..e0fe0e1 100644 --- a/Argo/StdModule.cc +++ b/Argo/StdModule.cc @@ -130,6 +130,7 @@ using ::std::optional; // expected using ::std::expected; +using ::std::unexpected; // NOLINTEND(bugprone-reserved-identifier) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1af251e..3cdf1f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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) @@ -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() diff --git a/Taskfile.yml b/Taskfile.yml index ad52ad5..ef8a62a 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,7 +15,7 @@ tasks: test: cmds: - task: build - - ./build/test-argo-release + - cmake --build build --target test silent: true report: cmds: