Adding more tests and excludes to be able to traverse through /**/* wihtout error
Added test summary to stdout
This commit is contained in:
@@ -53,6 +53,25 @@ rl::printPath() {
|
||||
fi
|
||||
}
|
||||
|
||||
rl::printTestSummary() {
|
||||
local success=${1:-0}
|
||||
local failed=${2:-0}
|
||||
local skipped=${3:-0}
|
||||
local total=$(( success + failed + skipped ))
|
||||
local separator="--------------------"
|
||||
|
||||
cat <<TEST_SUMMARY_EOF
|
||||
|
||||
# Test summary:
|
||||
successful: ${success}
|
||||
failed: ${failed}
|
||||
skipped: ${skipped}
|
||||
TEST_SUMMARY_EOF
|
||||
|
||||
printf "%15s-%s\n" "------" "${separator:0:${#total}}"
|
||||
printf "%15s %d\n" "total:" ${total}
|
||||
}
|
||||
|
||||
# rl::testcmp <TEST NUMBER> <TEST INPUT> <EXPECTED RESULT> <ACTUAL RESULT>
|
||||
# Compare results and print summary
|
||||
rl::testcmp() {
|
||||
@@ -111,6 +130,9 @@ rl::test() {
|
||||
local testend=0
|
||||
local arg=
|
||||
local excludemsg=
|
||||
local tests_success=0
|
||||
local tests_failed=0
|
||||
local tests_skipped=0
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$1" in
|
||||
@@ -163,22 +185,27 @@ rl::test() {
|
||||
|
||||
# Check for excludes
|
||||
elif excludemsg="$(toexclude "${firstelement}")"; then
|
||||
rl::printPath "$((i-1))" "${firstelement}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}"
|
||||
(( tests_skipped++ ))
|
||||
rl::printPath "$(( i/2 ))" "${firstelement}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}"
|
||||
# Execute tests
|
||||
else
|
||||
# Do the compare between two following elements
|
||||
if ! rl::testcmp "$((i-1))" "${firstelement}" \
|
||||
if ! rl::testcmp "$(( i/2 ))" "${firstelement}" \
|
||||
"${path}" "$($tool_rdlink -- "${firstelement}")"; then
|
||||
(( tests_failed++ ))
|
||||
# Run all tests if option -a is pressend
|
||||
(( ! $flag_runall )) && testend=1 && break
|
||||
else
|
||||
(( tests_success++ ))
|
||||
fi
|
||||
|
||||
firstelement=
|
||||
fi
|
||||
((i++))
|
||||
done
|
||||
(( testend )) && return 1
|
||||
(( testend )) && break
|
||||
done
|
||||
(( testend )) && rl::printTestSummary $tests_success $tests_failed $tests_skipped && return 1
|
||||
|
||||
# Initialize competition tests
|
||||
(( ! flag_onlyassert )) && tocompete_init
|
||||
@@ -206,19 +233,26 @@ rl::test() {
|
||||
else
|
||||
# Check for excludes
|
||||
if excludemsg="$(toexclude "${path}")" ; then
|
||||
rl::printPath "" "${path}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}"
|
||||
(( tests_skipped++ ))
|
||||
rl::printPath "${i}" "${path}" && printf " %b skip (%s)\n" "🛇" "${excludemsg}"
|
||||
# Execute tests
|
||||
elif ! rl::testcmp "${i}" "${path}" \
|
||||
"$(${tool_readlink} "$path")" "$(${tool_rdlink} -- "$path")"; then
|
||||
(( tests_failed++ ))
|
||||
# Run all tests if option -a is pressend
|
||||
(( ! $flag_runall )) && testend=1 && break
|
||||
else
|
||||
(( tests_success++ ))
|
||||
fi
|
||||
fi
|
||||
|
||||
((i++))
|
||||
done
|
||||
(( testend )) && return 1
|
||||
(( testend )) && break
|
||||
done
|
||||
|
||||
rl::printTestSummary $tests_success $tests_failed $tests_skipped
|
||||
(( testend )) && return 1 || return 0
|
||||
}
|
||||
|
||||
#time rl::test "$@"
|
||||
|
Reference in New Issue
Block a user