diff --git a/.github/actions/run-retry/action.yml b/.github/actions/run-retry/action.yml deleted file mode 100644 index 8b9ce13cd..000000000 --- a/.github/actions/run-retry/action.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: "Retry command" -description: "Retries a specified command up to a specified number of times." -inputs: - run: - description: "The command to run" - required: true - retries: - description: "Number of retries" - required: false - default: 3 -runs: - using: "composite" - steps: - - name: Run Command with Retry - shell: bash - run: | - command="${{ inputs.run }}" - retries=${{ inputs.retries }} - delay=${{ inputs.delay }} - attempt=1 - - until $command; do - if [ $attempt -ge $retries ]; then - echo "Attempt $attempt failed! No more retries left." - exit 1 - fi - echo "Attempt $attempt failed! Retrying in $delay seconds..." - attempt=$((attempt + 1)) - done - - echo "Command succeeded on attempt $attempt." diff --git a/.github/workflows/sonarcloud-analysis.yml b/.github/workflows/sonarcloud-analysis.yml index 25a6b50ca..c36a16335 100644 --- a/.github/workflows/sonarcloud-analysis.yml +++ b/.github/workflows/sonarcloud-analysis.yml @@ -82,9 +82,7 @@ jobs: - name: Integration tests coverage env: QT_QPA_PLATFORM: offscreen - uses: ./.github/actions/run-retry - with: - run: cmake --build build --target coverage-integtests + run: cmake --build build --target coverage-integtests - name: Get coverage report paths id: coverage-paths diff --git a/ChangeLog b/ChangeLog index a7244c4f9..00768b539 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Enhancements: - #7506 Make `APPLE_CODESIGN_ID` env var optional for CE CI - #7507 Add `run-retry` action to workaround `integtest` `gcovr` issue - #7509 Use GitHub vars to determine custom runner names +- #7510 Delete all `.gcda` files when integtests coverage fails # 1.16.0 diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index fe16201a8..a89c7dcea 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -583,6 +583,11 @@ macro(configure_coverage) set(test_exclude subprojects/* build/* src/test/*) set(test_src ${PROJECT_SOURCE_DIR}/src) + # Apparently solves the bug in gcov where it returns negative counts and confuses gcovr. + # > Got negative hit value in gcov line 'branch 2 taken -1' caused by a bug in gcov tool + # Bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-update=atomic") + setup_target_for_coverage_gcovr_xml( NAME coverage-${INTEG_TESTS_BIN} diff --git a/src/test/integtests/main.cpp b/src/test/integtests/main.cpp index b46889f8b..1960ce6c0 100644 --- a/src/test/integtests/main.cpp +++ b/src/test/integtests/main.cpp @@ -24,11 +24,17 @@ #include "arch/win32/ArchMiscWindows.h" #endif +#include #include using synergy::test::ExitTimeout; +const auto testDir = "tmp/test"; + int main(int argc, char **argv) { + // HACK: Unit tests should not use the filesystem. + std::filesystem::create_directories(testDir); + ExitTimeout exitTimeout(1, "Integration tests"); #if SYSAPI_WIN32 diff --git a/src/test/unittests/base/PathTests.cpp b/src/test/unittests/base/PathTests.cpp index fad376fdd..159de116c 100644 --- a/src/test/unittests/base/PathTests.cpp +++ b/src/test/unittests/base/PathTests.cpp @@ -16,7 +16,6 @@ */ #include "base/Path.h" -#include #include #include @@ -25,8 +24,6 @@ const std::string testDir = "tmp/test"; const std::wstring testDirW = L"tmp/test"; TEST(PathTests, open_file_using_path) { - std::filesystem::create_directories(testDir); - std::string utf8FileName = testDir + "/тіás.txt"; #if SYSAPI_WIN32 // Windows uses UTF-16 for file path and names diff --git a/src/test/unittests/main.cpp b/src/test/unittests/main.cpp index d9f6586f7..7e51d9ec2 100644 --- a/src/test/unittests/main.cpp +++ b/src/test/unittests/main.cpp @@ -24,11 +24,17 @@ #include "arch/win32/ArchMiscWindows.h" #endif +#include #include using synergy::test::ExitTimeout; +const auto testDir = "tmp/test"; + int main(int argc, char **argv) { + // HACK: Unit tests should not use the filesystem. + std::filesystem::create_directories(testDir); + ExitTimeout exitTimeout(1, "Unit tests"); #if SYSAPI_WIN32 diff --git a/src/test/unittests/synergy/X11LayoutParserTests.cpp b/src/test/unittests/synergy/X11LayoutParserTests.cpp index 32076baca..3dc40b85b 100644 --- a/src/test/unittests/synergy/X11LayoutParserTests.cpp +++ b/src/test/unittests/synergy/X11LayoutParserTests.cpp @@ -18,15 +18,12 @@ #if WINAPI_XWINDOWS #include "synergy/unix/X11LayoutsParser.h" -#include #include #include const std::string testDir = "tmp/test"; void createTestFiles() { - std::filesystem::create_directories(testDir); - std::ofstream correctEvdevFile(testDir + "/correctEvdev.xml"); if (!correctEvdevFile.is_open()) { FAIL();