Skip to content
Snippets Groups Projects
Commit a1ced2d1 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[duneci-standard-test] Restructure to make default values visible.

Ansgar prefers a pattern of the form
```sh
VAR=default_value
if explicitly_configured; then
  VAR=configured_value
fi
```
This restructures the labels parsing the make this pattern possible.
parent 1f80d2d3
Branches
No related tags found
No related merge requests found
...@@ -21,43 +21,48 @@ if [[ -v DUNECI_PARALLEL ]]; then ...@@ -21,43 +21,48 @@ if [[ -v DUNECI_PARALLEL ]]; then
parallel_opts="-j${DUNECI_PARALLEL}" parallel_opts="-j${DUNECI_PARALLEL}"
fi fi
# Evaluate $DUNECI_TEST_LABELS and set $build_test_target and # Parse labels in $1 and set ${parsed_targets[@]} and ${parsed_selectors[@]}
# $labels_regex_arg accordingly. Labels in $DUNECI_TEST_LABELS may be # accordingly. Labels in $1 may be seperated by whitespace or ','.
# seperated by whitespace or ','. parse_labels()
handle_labels()
{ {
# use a function to automatically restore IFS # use a function to automatically restore IFS
local IFS=$IFS, label labels labels_regexs local IFS="$IFS," label regexs status=1
labels=(${DUNECI_TEST_LABELS-})
if [[ ${#labels[@]} -eq 0 ]]; then parsed_targets=()
build_test_targets=(build_tests) regexs=()
labels_regex_arg= for label in $1; do
else # ensure the labels can be safely handled
build_test_targets=() if [[ -z $label ]] || [[ $label == *[![:word:]-]* ]]; then
labels_regexs=() cat >&2 <<EOF
for label in "${labels[@]}"; do
# ensure the labels can be safely handled
if [[ -z $label ]] || [[ $label == *[![:word:]-]* ]]; then
cat >&2 <<EOF
duneci-standard-test: Error: Invalid label in DUNECI_TEST_LABELS: '$label' duneci-standard-test: Error: Invalid label in DUNECI_TEST_LABELS: '$label'
duneci-standard-test: Note: Only alphanumeric characters plus '_' and '-' are duneci-standard-test: Note: Only alphanumeric characters plus '_' and '-' are
duneci-standard-test: Note: allowed in label names, and the names must be duneci-standard-test: Note: allowed in label names, and the names must be
duneci-standard-test: Note: non-empty. duneci-standard-test: Note: non-empty.
EOF EOF
exit 2 exit 2
fi fi
build_test_targets+=("build_${label}_tests") parsed_targets+=("build_${label}_tests")
labels_regexs+=("^${label}\$") regexs+=("^${label}\$")
done status=0 # we found at least one label
done
parsed_selectors=()
if [[ ${#regexs[@]} -gt 0 ]]; then
# This will join all regexps using '|' from IFS # This will join all regexps using '|' from IFS
IFS="|" IFS="|"
labels_regex_arg="${labels_regexs[*]}" parsed_selectors=(-L "${regexs[*]}")
# This will quote the result for when dunecontrol evals the parameters
labels_regex_arg="-L ${labels_regex_arg@Q}"
fi fi
return $status
} }
handle_labels
build_test_targets=(build_tests) # passed to make/ninja to build tests
select_test_args=() # passed to ctest to select tests
if parse_labels "${DUNECI_TEST_LABELS-}"; then
build_test_target=("${parsed_targets[@]}")
select_test_args=("${parsed_selectors[@]}")
fi
# Allow oversubscription (tests might want to try having more ranks # Allow oversubscription (tests might want to try having more ranks
# than environment has processors) and force degraded mode (as we # than environment has processors) and force degraded mode (as we
...@@ -74,4 +79,5 @@ set -x ...@@ -74,4 +79,5 @@ set -x
${DUNECONTROL} --current "${@}" vcsetup ${DUNECONTROL} --current "${@}" vcsetup
${DUNECONTROL} --current "${@}" configure ${DUNECONTROL} --current "${@}" configure
${DUNECONTROL} --current "${@}" make ${parallel_opts} all "${build_test_targets[@]}" ${DUNECONTROL} --current "${@}" make ${parallel_opts} all "${build_test_targets[@]}"
${DUNECONTROL} --current "${@}" bexec ${DUNE_CTEST} ${parallel_opts} "$labels_regex_arg" # note the extra quoting for select_test_args to protect it from dunecontrol evaling it
${DUNECONTROL} --current "${@}" bexec ${DUNE_CTEST} ${parallel_opts} "${select_test_args[@]@Q}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment