diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 99e4f8c..9075065 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -10,7 +10,7 @@ jobs: fail-fast: false matrix: config: - - name: "Ubuntu latest GCC 9.3" + - name: "Ubuntu 20.04 GCC 9.3" os: ubuntu-20.04 build_type: Release packages: ninja-build @@ -18,6 +18,14 @@ jobs: cc: gcc cxx: g++ + - name: "Ubuntu 20.04 GCC 9.3 coverage" + os: ubuntu-20.04 + build_type: Debug + packages: ninja-build lcov + generator: Ninja + cc: gcc + cxx: g++ + - name: "Ubuntu 18.04 GCC 8.4" os: ubuntu-18.04 build_type: Release @@ -26,6 +34,14 @@ jobs: cc: gcc-8 cxx: g++-8 + - name: "Ubuntu 18.04 GCC 7.5" + os: ubuntu-18.04 + build_type: Release + packages: ninja-build + generator: Ninja + cc: gcc-7 + cxx: g++-7 + - name: "Windows MSVC 2019" os: windows-latest build_type: Release @@ -52,8 +68,12 @@ jobs: - name: Install dependencies on Ubuntu if: startsWith(matrix.config.os, 'ubuntu') + shell: bash run: | sudo apt install ${{ matrix.config.packages }} + if [[ "${{ matrix.config.build_type }}" == "Debug" ]]; then + gem install coveralls-lcov + fi - name: Install dependencies on windows if: startsWith(matrix.config.os, 'windows') @@ -74,11 +94,24 @@ jobs: cmake --version mkdir build mkdir install - cmake -G "${{ matrix.config.generator }}" -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_INSTALL_PREFIX:PATH=install + if [[ "${{ matrix.config.build_type }}" == "Debug" ]]; then + cmake -G "${{ matrix.config.generator }}" -S . -B build -DCMAKE_BUILD_TYPE=Debug -DGHC_COVERAGE=ON -DCMAKE_INSTALL_PREFIX:PATH=install + else + cmake -G "${{ matrix.config.generator }}" -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} -DCMAKE_INSTALL_PREFIX:PATH=install + fi - name: Build project shell: bash - run: cmake --build build --config ${{ matrix.config.build_type }} + run: | + cmake --build build --config ${{ matrix.config.build_type }} - name: Run tests - run: cd build && ctest -C ${{ matrix.config.build_type }} + run: | + cd build && ctest -C ${{ matrix.config.build_type }} + + - name: Collect coverage info + run: | + cd build + lcov --compat-libtool --directory . --capture --output-file coverage_output.info + lcov --remove coverage_output.info '/usr/*' '*/c++/*' '*.h' '*/catch.hpp' -o coverage.info + sed -i 's|SF:/.*/filesystem/|SF:../|g' coverage.info \ No newline at end of file diff --git a/cmake/GhcHelper.cmake b/cmake/GhcHelper.cmake index f7cdb52..8fffae9 100644 --- a/cmake/GhcHelper.cmake +++ b/cmake/GhcHelper.cmake @@ -52,7 +52,8 @@ macro(AddTestExecutableWithStdCpp cppStd) $<$,$>:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Werror -Wno-error=deprecated-declarations> $<$:-Wall -Wextra -Wshadow -Wconversion -Wsign-conversion -Wpedantic -Wno-psabi -Werror -Wno-error=deprecated-declarations> $<$:/WX /wd4996> - $<$:-Wa,-mbig-obj>) + $<$:-Wa,-mbig-obj> + $<$:--coverage>) if(CMAKE_CXX_COMPILER_ID MATCHES MSVC) target_compile_definitions(filesystem_test_cpp${cppStd} PRIVATE _CRT_SECURE_NO_WARNINGS) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b926706..f9fdd18 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,6 +13,12 @@ if(GHC_COVERAGE) target_compile_options(filesystem_test PUBLIC --coverage) endif() target_link_libraries(filesystem_test PUBLIC ghc_filesystem --coverage) + if("cxx_std_17" IN_LIST GHC_FILESYSTEM_TEST_COMPILE_FEATURES) + AddTestExecutableWithStdCpp(17 filesystem_test.cpp catch.hpp) + endif() + if("cxx_std_20" IN_LIST GHC_FILESYSTEM_TEST_COMPILE_FEATURES) + AddTestExecutableWithStdCpp(20 filesystem_test.cpp catch.hpp) + endif() else() message("Generating test runner for normal test...") add_executable(filesystem_test filesystem_test.cpp catch.hpp)