diff --git a/scripts/find-suites.sh b/scripts/find-suites.sh index 41b9b5e61..0d7df5f6d 100755 --- a/scripts/find-suites.sh +++ b/scripts/find-suites.sh @@ -12,15 +12,46 @@ set -euo pipefail # ensure dir cd -P -- "$(dirname -- "$0")/.." +DIR="$1" + +complete_path() { + local filename="$1" + # Check if path prefix is present + if [[ "$filename" != */* ]]; then + filename="$DIR/test/$filename" + fi + + # Check if suffix is present + if [[ "$filename" != *.erl ]]; then + filename="$filename.erl" + fi + + echo "$filename" +} ## EMQX_CT_SUITES or SUITES is useful in ad-hoc runs EMQX_CT_SUITES="${EMQX_CT_SUITES:-${SUITES:-}}" if [ -n "${EMQX_CT_SUITES:-}" ]; then - echo "${EMQX_CT_SUITES}" + OUTPUT="" + IFS=',' read -ra FILE_ARRAY <<< "$EMQX_CT_SUITES" + for file in "${FILE_ARRAY[@]}"; do + path=$(complete_path "$file") + if [ ! -f "$path" ]; then + echo '' + echo "ERROR: '$path' is not a file. Ignored!" >&2 + exit 1 + fi + if [ -z "$OUTPUT" ]; then + OUTPUT="$path" + else + OUTPUT="$OUTPUT,$path" + fi + done + echo "${OUTPUT}" exit 0 fi -TESTDIR="$1/test" -INTEGRATION_TESTDIR="$1/integration_test" +TESTDIR="$DIR/test" +INTEGRATION_TESTDIR="$DIR/integration_test" # Get the output of the find command IFS=$'\n' read -r -d '' -a FILES < <(find "${TESTDIR}" -name "*_SUITE.erl" 2>/dev/null | sort && printf '\0') if [[ -d "${INTEGRATION_TESTDIR}" ]]; then