test: make find-suites.sh smarter

This commit is contained in:
Zaiming (Stone) Shi 2023-10-30 16:27:03 +01:00
parent 62d7fdccf9
commit f3c79738d4
1 changed files with 34 additions and 3 deletions

View File

@ -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