From e040e087a27a1b050863262ec3fb92b1adee082c Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Wed, 26 Apr 2023 15:25:05 +0200 Subject: [PATCH] Fix sporadic CI/CD failures due to race condition When running tests in parallel, there was a case where two tests accessed the same generated resource. This is resolved by moving all regression tests into their own subdirectory. --- tests/tests_regression/CMakeLists.txt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/tests_regression/CMakeLists.txt b/tests/tests_regression/CMakeLists.txt index 779e2a42..686ae049 100644 --- a/tests/tests_regression/CMakeLists.txt +++ b/tests/tests_regression/CMakeLists.txt @@ -54,29 +54,37 @@ set(TABLES_TO_COMPARE ) function(test_standard standard base_config resource_dir output_filename) - configure_file(compare.sh compare-${standard}.sh) + # Put all the generated files into a subdirectory + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${standard}) + + configure_file(compare.sh ${standard}/compare.sh) # Test to create database add_test( NAME Regression${standard}.CreateDatabase + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${standard} COMMAND $ ${base_config} ${resource_dir} ) set_tests_properties(Regression${standard}.CreateDatabase PROPERTIES FIXTURES_SETUP Regression${standard}.CreateDatabase) - # Test to diff the whole database + # Test to diff the whole database. This test should not fail. + # The purpose of this test is solely to output the differences of the two databases + # so that they can be inspected easily. add_test( NAME Regression${standard}.SqlDiff - COMMAND compare-${standard}.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${standard} + COMMAND compare.sh ) set_tests_properties(Regression${standard}.SqlDiff PROPERTIES FIXTURES_REQUIRED Regression${standard}.CreateDatabase) # Tests to diff individual tables foreach(table IN LISTS TABLES_TO_COMPARE) - configure_file(compare_table.sh compare_table-${table}-${standard}.sh) + configure_file(compare_table.sh ${standard}/compare_table-${table}.sh) add_test( NAME Regression${standard}.SqlDiff.${table} - COMMAND compare_table-${table}-${standard}.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${standard} + COMMAND compare_table-${table}.sh ) set_tests_properties(Regression${standard}.SqlDiff.${table} PROPERTIES FIXTURES_REQUIRED Regression${standard}.CreateDatabase) endforeach()