summaryrefslogtreecommitdiff
path: root/src/shtests.sh
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-03-03 18:38:37 +0000
committerdavidovski <david@davidovski.xyz>2022-03-03 18:38:37 +0000
commitd9091aea868392a181317a0609870273adf2c094 (patch)
tree671eb4b33036ff095978030bef62b40fb09f1733 /src/shtests.sh
parente989ac4788a3f947ce0097effdccaabd62c5a8ff (diff)
fixed everything to work with posix shellv1.0.2
Diffstat (limited to 'src/shtests.sh')
-rw-r--r--src/shtests.sh22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/shtests.sh b/src/shtests.sh
index 9994d7b..70dc21b 100644
--- a/src/shtests.sh
+++ b/src/shtests.sh
@@ -14,29 +14,35 @@
PASS="${BLUE}[ ${GREEN}PASS${BLUE} ]${RESET}"
FAIL="${BLUE}[ ${RED}FAIL${BLUE} ]${RESET}"
+V=false
+
runtest () {
- test_name=$(sed "s/_/ /g" <<< "$1")
+ test_name=$(echo $1 | sed "s/_/ /g")
test_func="$2"
- printf "${BLUE}[ ] ${RESET}$test_name\r";
+ printf "${BLUE}[ ] ${RESET}$test_name ";
if "$test_func" ; then
- printf "$PASS\n"
+ printf "\r$PASS\n"
return 0
else
- printf "$FAIL\n"
+ printf "\r$FAIL\n"
return 1
fi
}
+# TODO use getopt for this
+if [ "$1" = "-v" ]; then
+ shift
+ V=true
+fi
+
if [ $# = "0" ]; then
printf "${RED}No tests file has been provided\n"
exit 1;
else
- source $@
+ . $@
fi
-
-tests=$(declare -F | sed -rn "s/declare -f test_(.+)/\1/p")
-
+tests=$(sed -n "s/^test_\(.*\)\s*()\s*{/\1/p" $@)
total=$(echo $tests | wc -w)
passed=0
failed=0