diff --git a/.github/workflows/workflow.yaml b/.github/workflows/workflow.yaml index d510b598dd..59ceb6bb53 100644 --- a/.github/workflows/workflow.yaml +++ b/.github/workflows/workflow.yaml @@ -34,14 +34,14 @@ jobs: - name: CMake Generation run: | cmake --version - cmake -B build + cmake -B build -DCODE_COVERAGE=ON - name: Build Project run: | cd build - make -j2 + make -j - name: Run Tests timeout-minutes: 5 - run: ./test.sh + run: ./test_code_coverage.sh - name: Coveralls uses: coverallsapp/github-action@master with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 2836a1fc54..905e3426bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,11 +33,15 @@ IF (WIN32) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) ENDIF() +option(CODE_COVERAGE "Enable Code Coverage Compiler Flags" OFF) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules/) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND CODE_COVERAGE) include(CodeCoverage) append_coverage_compiler_flags() + message("Code Coverage build is enabled!") +else() + message("Code Coverage build is disabled!") endif() # includes relative to top level jak-project folder diff --git a/test.sh b/test.sh index 482651ed02..573dafc226 100755 --- a/test.sh +++ b/test.sh @@ -5,5 +5,4 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" export NEXT_DIR=$DIR export FAKE_ISO_PATH=/game/fake_iso.txt -cd $DIR/build/ -make goalc-test_coverage +$DIR/build/test/goalc-test --gtest_color=yes "$@" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 989eb211a4..b10147fc59 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,7 +25,7 @@ ELSE() target_link_libraries(goalc-test goos util listener runtime compiler type_system gtest) ENDIF() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND CODE_COVERAGE) include(CodeCoverage) append_coverage_compiler_flags() setup_target_for_coverage_lcov(NAME goalc-test_coverage diff --git a/test_code_coverage.sh b/test_code_coverage.sh new file mode 100755 index 0000000000..482651ed02 --- /dev/null +++ b/test_code_coverage.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Directory of this script +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +export NEXT_DIR=$DIR +export FAKE_ISO_PATH=/game/fake_iso.txt +cd $DIR/build/ +make goalc-test_coverage