33# The test parent dir to be cretaed in current directory
44TEST_PARENT_DIR_PWG=" o2dpg_tests/workflows_pwgs"
55TEST_PARENT_DIR_BIN=" o2dpg_tests/workflows_bin"
6+ TEST_PARENT_DIR_ANCHORED=" o2dpg_tests/anchored"
67
78# a global counter for tests
89TEST_COUNTER=0
910
1011# unified names of log files
1112LOG_FILE_WF=" o2dpg-test-wf.log"
13+ LOG_FILE_ANCHORED=" o2dpg-test-anchored.log"
1214
1315# Prepare some colored output
1416SRED=" \033[0;31m"
@@ -123,6 +125,26 @@ run_workflow_creation()
123125 return ${RET}
124126}
125127
128+ test_anchored ()
129+ {
130+ local to_run=" ${1:- ${O2DPG_ROOT} / MC/ run/ ANCHOR/ tests/ test_anchor_2023_apass2_pp.sh} "
131+ local RET=0
132+ for anchored_script in ${to_run} ; do
133+ [[ ! -f ${anchored_script} ]] && { echo " Desired test script ${anchored_script} does not exist. Skip." ; continue ; }
134+ (( TEST_COUNTER++ ))
135+ local test_dir=${TEST_COUNTER} _$( basename ${anchored_script} ) _dir
136+ rm -rf ${test_dir} 2> /dev/null
137+ mkdir ${test_dir}
138+ pushd ${test_dir} > /dev/null
139+ echo -n " Test ${TEST_COUNTER} : ${anchored_script} "
140+ ${anchored_script} >> ${LOG_FILE_ANCHORED} 2>&1
141+ local ret_this=${?}
142+ [[ " ${ret_this} " != " 0" ]] && RET=${ret_this}
143+ popd > /dev/null
144+ done
145+ return ${RET}
146+ }
147+
126148collect_changed_pwg_wf_files ()
127149{
128150 # Collect all INI files which have changed
@@ -188,8 +210,9 @@ source ${REPO_DIR}/test/common/utils/utils.sh
188210pushd ${REPO_DIR} > /dev/null
189211
190212# flag if anything changed in the sim workflow bin dir
191- changed_wf_bin=$( get_changed_files | grep " MC/bin" )
213+ changed_wf_bin=$( get_changed_files | grep -E " MC/bin" )
192214changed_wf_bin_related=$( get_changed_files | grep -E " MC/analysis_testing|MC/config/analysis_testing/json|MC/config/QC/json" )
215+ changed_anchored_related=$( get_changed_files | grep -E " MC/run/ANCHOR/anchorMC.sh|MC/run/ANCHOR/tests|MC/bin|UTILS/parse-async-WorkflowConfig.py" )
193216
194217
195218# collect what has changed for PWGs
@@ -215,6 +238,27 @@ REPO_DIR=$(realpath ${REPO_DIR})
215238export O2DPG_ROOT=${REPO_DIR}
216239
217240
241+ # ##############
242+ # ANCHORED MC #
243+ # ##############
244+ # prepare our local test directory for PWG tests
245+ rm -rf ${TEST_PARENT_DIR_ANCHORED} 2> /dev/null
246+ mkdir -p ${TEST_PARENT_DIR_ANCHORED} 2> /dev/null
247+ pushd ${TEST_PARENT_DIR_ANCHORED} > /dev/null
248+
249+ # global return code for PWGs
250+ ret_global_anchored=0
251+ if [[ " ${changed_anchored_related} " != " " ]] ; then
252+ echo " ### Test anchored ###"
253+ # Run an anchored test
254+ test_anchored
255+ ret_global_anchored=${?}
256+ echo
257+ fi
258+
259+ # return to where we came from
260+ popd > /dev/null
261+
218262# #######
219263# PWGs #
220264# #######
@@ -226,7 +270,7 @@ pushd ${TEST_PARENT_DIR_PWG} > /dev/null
226270# global return code for PWGs
227271ret_global_pwg=0
228272if [[ " ${changed_wf_bin} " != " " ]] ; then
229- # Run all the PWG related WF creations, hence overwrite what was collected by collect_changed_pwg_wf_files eal=rlier
273+ # Run all the PWG related WF creations, hence overwrite what was collected by collect_changed_pwg_wf_files earlier
230274 WF_FILES=$( get_all_workflows " MC/run/.*/" )
231275 echo
232276fi
@@ -240,7 +284,6 @@ if [[ "${WF_FILES}" != "" ]] ; then
240284 echo
241285fi
242286
243-
244287# return to where we came from
245288popd > /dev/null
246289
@@ -285,9 +328,21 @@ if [[ "${ret_global_bin}" != "0" ]] ; then
285328 echo " ###################################"
286329 echo
287330 print_error_logs ${TEST_PARENT_DIR_BIN}
288- exit ${ret_global_bin}
289331fi
290332
333+ # However, if a central test fails, exit code will be !=0
334+ if [[ " ${ret_global_anchored} " != " 0" ]] ; then
335+ echo
336+ echo " ##########################"
337+ echo " # ERROR for anchored MCs #"
338+ echo " ##########################"
339+ echo
340+ print_error_logs ${TEST_PARENT_DIR_ANCHORED}
341+ fi
342+
343+ RET=$(( ret_global_bin + ret_global_anchored ))
344+
291345echo
292- echo_green " All required workflow tests successful"
293- echo
346+ [[ " ${RET} " != " 0" ]] && echo " There were errors, please check!" || echo_green " All required workflow tests successful"
347+
348+ exit ${RET}
0 commit comments