diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f5982a..c5fbfd8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ on: push: branches: - main - - test + - "*" pull_request: types: [opened, synchronize, reopened] jobs: @@ -13,11 +13,14 @@ jobs: env: BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v3.2.0 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Install sonar-scanner and build-wrapper uses: SonarSource/sonarcloud-github-c-cpp@v1 + - name: Install gcovr + run: | + sudo apt-get install -y gcovr - name: Tests & build-wrapper run: | mkdir build @@ -29,6 +32,7 @@ jobs: build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build/ --config Release cd build ctest -C Release --output-on-failure + gcovr --root .. --gcov-filter "CPPFImdlp.cpp" --gcov-filter "Metrics.cpp" --txt --sonarqube=coverage.xml - name: Run sonar-scanner env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 31a7b4d..9446e2b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,5 @@ .idea cmake-* **/CMakeFiles -.vscode/* \ No newline at end of file +.vscode/* +**/gcovr-report \ No newline at end of file diff --git a/CPPFImdlp.cpp b/CPPFImdlp.cpp index e0d2f95..a2c17ce 100644 --- a/CPPFImdlp.cpp +++ b/CPPFImdlp.cpp @@ -128,9 +128,6 @@ namespace mdlp { precision_t ig, delta; precision_t ent, ent1, ent2; auto N = precision_t(end - start); - if (N < 2) { - return false; - } k = metrics.computeNumClasses(start, end); k1 = metrics.computeNumClasses(start, cut); k2 = metrics.computeNumClasses(cut, end); diff --git a/tests/cover b/tests/cover deleted file mode 100755 index 3f2aca6..0000000 --- a/tests/cover +++ /dev/null @@ -1,4 +0,0 @@ -rm -fr lcoverage/* -lcov --capture --directory ./ --output-file lcoverage/main_coverage.info -genhtml lcoverage/main_coverage.info --output-directory lcoverage -open lcoverage/index.html diff --git a/tests/test b/tests/test index 5bacf1f..fb44da9 100755 --- a/tests/test +++ b/tests/test @@ -1,12 +1,16 @@ +if [ -d build ] ; then + rm -fr build +fi cmake -S . -B build -Wno-dev -if test $? -ne 0; then - echo "Error in creating build commands." - exit 1 -fi cmake --build build -if test $? -ne 0; then - echo "Error in build command." - exit 1 -fi cd build -ctest --output-on-failure|grep -v profiling +ctest --output-on-failure +cd .. +if [ ! -d lcoverage ] ; then + mkdir lcoverage +fi +rm -fr lcoverage/* 2>/dev/null +#lcov --capture --directory ./ --output-file lcoverage/main_coverage.info +#lcov --remove lcoverage/main_coverage.info 'v1/*' '/Applications/*' '*/tests/*' --output-file lcoverage/main_coverage.info -q +#lcov --list lcoverage/main_coverage.info +gcovr --root .. --gcov-filter "CPPFImdlp.cpp" --gcov-filter "Metrics.cpp" --txt --sonarqube=coverage.xml