tests: Removed awk call

This commit is contained in:
Dylan Araps
2018-06-18 09:20:23 +10:00
parent c9768e2b45
commit 5f61ee3885

12
test.sh
View File

@@ -129,9 +129,9 @@ test_date() {
} }
test_read_sleep() { test_read_sleep() {
result="$SECONDS" result="$((SECONDS+1))"
read_sleep 1 read_sleep 1
assert_equals "$((result+1))" "$SECONDS" assert_equals "$result" "$SECONDS"
} }
test_bar() { test_bar() {
@@ -164,10 +164,12 @@ main() {
printf '\n%s\n%s\n' "$head" "${head//?/-}" printf '\n%s\n%s\n' "$head" "${head//?/-}"
# Generate the list of tests to run. # Generate the list of tests to run.
IFS=$'\n' read -d "" -ra funcs < <(awk -F'(' '/^test_/ {print $1}' "$0") IFS=$'\n' read -d "" -ra funcs < <(declare -F)
for func in "${funcs[@]}"; do "$func"; done for func in "${funcs[@]//declare -f }"; do
[[ "$func" == test_* ]] && { "$func"; ((tot+=1)); }
done
comp="Completed ${#funcs[@]} tests. ${pass:-0} passed, ${fail:-0} failed." comp="Completed $tot tests. ${pass:-0} passed, ${fail:-0} failed."
printf '%s\n%s\n\n' "${comp//?/-}" "$comp" printf '%s\n%s\n\n' "${comp//?/-}" "$comp"
rm readme_code rm readme_code