From 3b50d78f1ec4c332ca1d00ff6cf4c933774f4871 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 13 Oct 2021 00:14:35 +0200 Subject: [PATCH] Use resource lock to avoid concurrent execution of tests requiring Syncthing test instance This is likely the cleaner approach compared to just enforcing a serial run for the CLI test. --- cli/CMakeLists.txt | 4 ++-- connector/CMakeLists.txt | 5 +++++ libsyncthing/CMakeLists.txt | 5 +++++ testhelper/CMakeLists.txt | 5 +++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 631b216..ae58922 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -44,7 +44,7 @@ include(ShellCompletion) include(Doxygen) include(ConfigHeader) -# avoid running this test in parallel with other tests as it interferes with the connector test +# avoid running this test in parallel with other tests spawning a Syncthing test instance if (META_MAIN_TEST_NAME) - set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RUN_SERIAL TRUE) + set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance") endif () diff --git a/connector/CMakeLists.txt b/connector/CMakeLists.txt index f903be8..3b82c49 100644 --- a/connector/CMakeLists.txt +++ b/connector/CMakeLists.txt @@ -137,5 +137,10 @@ include(LibraryTarget) list(APPEND TEST_LIBRARIES syncthingtesthelper) include(TestTarget) +# avoid running this test in parallel with other tests spawning a Syncthing test instance +if (META_MAIN_TEST_NAME) + set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance") +endif () + include(Doxygen) include(ConfigHeader) diff --git a/libsyncthing/CMakeLists.txt b/libsyncthing/CMakeLists.txt index 2ae1dc1..9bb1f74 100644 --- a/libsyncthing/CMakeLists.txt +++ b/libsyncthing/CMakeLists.txt @@ -248,3 +248,8 @@ if (NOT BUILD_SHARED_LIBS DESTINATION "lib${SELECTED_LIB_SUFFIX}" COMPONENT binary) endif () + +# avoid running this test in parallel with other tests spawning a Syncthing test instance +if (META_MAIN_TEST_NAME) + set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance") +endif () diff --git a/testhelper/CMakeLists.txt b/testhelper/CMakeLists.txt index a24a83d..fbdaa48 100644 --- a/testhelper/CMakeLists.txt +++ b/testhelper/CMakeLists.txt @@ -49,3 +49,8 @@ include(ConfigHeader) # exclude the target from 'all' target so it is only built when tests are built set_target_properties("${META_TARGET_NAME}" PROPERTIES EXCLUDE_FROM_ALL ON) + +# avoid running this test in parallel with other tests spawning a Syncthing test instance +if (META_MAIN_TEST_NAME) + set_tests_properties("${META_MAIN_TEST_NAME}" PROPERTIES RESOURCE_LOCK "syncthingtestinstance") +endif ()