Make brief output the default and add option -x and -xd instead of -o and -oo
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
# test_rdlink.sh [OPTIONS] [PATH TO COMPETE]
|
# test_rdlink.sh [OPTIONS] [PATH TO COMPETE]
|
||||||
# [OPTIONS]
|
# [OPTIONS]
|
||||||
# -a, --run-all : Run all tests (failed and successful)
|
# -a, --run-all : Run all tests (failed and successful)
|
||||||
# -o, --only-result : Show only result (input <> expected)
|
# -x, --extended-output : Show more information for each test
|
||||||
|
# -xd : set -x and also show rdlink debug run for failed tests
|
||||||
#
|
#
|
||||||
# Internal tests will be executed if no arguments are found
|
# Internal tests will be executed if no arguments are found
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ readonly color_green='\033[1;32m'
|
|||||||
readonly color_less='\033[0m'
|
readonly color_less='\033[0m'
|
||||||
|
|
||||||
flag_runall=0
|
flag_runall=0
|
||||||
flag_onlyresult=0
|
flag_extendedOutput=0
|
||||||
flag_verbose=0
|
flag_verbose=0
|
||||||
|
|
||||||
toassert=()
|
toassert=()
|
||||||
@@ -41,25 +42,12 @@ rl::testcmp() {
|
|||||||
local actual="${4:-"-"}"
|
local actual="${4:-"-"}"
|
||||||
local testresult=0 #failed
|
local testresult=0 #failed
|
||||||
local testresult_graphic="${color_red}✗${color_less}" # alt. symbol ≠
|
local testresult_graphic="${color_red}✗${color_less}" # alt. symbol ≠
|
||||||
|
local truncate_graphic=
|
||||||
|
|
||||||
[[ "${expect}" == "${actual}" ]] && testresult=1 && testresult_graphic="${color_green}✔${color_less}" # alt. symbol ✓
|
[[ "${expect}" == "${actual}" ]] && testresult=1 && testresult_graphic="${color_green}✔${color_less}" # alt. symbol ✓
|
||||||
|
|
||||||
# Show only reslult as quick overview
|
# Show only reslult as quick overview
|
||||||
if (( flag_onlyresult )); then
|
if (( flag_extendedOutput )); then
|
||||||
# Change result graphic if test failed
|
|
||||||
(( ! testresult )) && testresult_graphic="→" # "${color_green}→${color_less}"
|
|
||||||
# Truncate input string on the left if longer than $config_path_width
|
|
||||||
(( ${#input} > ${config_path_width} )) && input="<-${input:$(( ${#input} - ${config_path_width} + 2 ))}"
|
|
||||||
# Print input and expected
|
|
||||||
printf "%${config_path_width}s %b %s\n" "${input}" "${testresult_graphic}" "${expect}"
|
|
||||||
# Print actual result if test failed
|
|
||||||
if (( ! testresult )); then
|
|
||||||
printf "%$((config_path_width))s %b %s\n" " " "${color_red}✗${color_less}" "${actual}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}"
|
printf -- "%-3d Inp: %-${config_path_width}s ---" ${testnum} "${input}"
|
||||||
printf " %b\n" "${testresult_graphic}"
|
printf " %b\n" "${testresult_graphic}"
|
||||||
if (( ! testresult )); then
|
if (( ! testresult )); then
|
||||||
@@ -76,6 +64,20 @@ rl::testcmp() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change result graphic if test failed
|
||||||
|
(( ! testresult )) && testresult_graphic="→" # "${color_green}→${color_less}"
|
||||||
|
# Truncate input string on the left if longer than $config_path_width
|
||||||
|
(( ${#input} > ${config_path_width} )) && input="${input:$(( ${#input} - ${config_path_width} + 1 ))}" && truncate_graphic="✀"
|
||||||
|
# Print input and expected
|
||||||
|
printf "%b%${config_path_width}s %b %s\n" "${truncate_graphic}" "${input}" "${testresult_graphic}" "${expect}"
|
||||||
|
# Print actual result if test failed
|
||||||
|
if (( ! testresult )); then
|
||||||
|
printf "%$((config_path_width))s %b %s\n" " " "${color_red}✗${color_less}" "${actual}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
rl::test() {
|
rl::test() {
|
||||||
@@ -93,10 +95,11 @@ rl::test() {
|
|||||||
-a|--run-all) ## Run all even if tests fail
|
-a|--run-all) ## Run all even if tests fail
|
||||||
flag_runall=1
|
flag_runall=1
|
||||||
shift ;;
|
shift ;;
|
||||||
-o|--only-result)
|
-x|--extended-output)
|
||||||
flag_onlyresult=1
|
flag_extendedOutput=1
|
||||||
shift ;;
|
shift ;;
|
||||||
-v|--verbose)
|
-xd|--verbose)
|
||||||
|
flag_extendedOutput=1
|
||||||
flag_verbose=1
|
flag_verbose=1
|
||||||
shift ;;
|
shift ;;
|
||||||
esac
|
esac
|
||||||
@@ -118,7 +121,7 @@ rl::test() {
|
|||||||
if (( ! i )); then
|
if (( ! i )); then
|
||||||
# Print title in array element 0
|
# Print title in array element 0
|
||||||
printf " ### %b ###\n" "${color_yellow}${path}${color_less}"
|
printf " ### %b ###\n" "${color_yellow}${path}${color_less}"
|
||||||
(( flag_onlyresult )) && printf "%${config_path_width}s %s %s\n" "<INPUT>" "<EXPECTED>" "✗ [ACTUAL]"
|
(( ! flag_extendedOutput )) && printf "%${config_path_width}s %s %s\n" "<INPUT>" "<EXPECTED>" "✗ [ACTUAL]"
|
||||||
|
|
||||||
elif [ -z "$firstelement" ]; then
|
elif [ -z "$firstelement" ]; then
|
||||||
# Save first element for string compare
|
# Save first element for string compare
|
||||||
@@ -149,7 +152,7 @@ rl::test() {
|
|||||||
if (( ! i )); then
|
if (( ! i )); then
|
||||||
# Print title in array element 0
|
# Print title in array element 0
|
||||||
printf " ### %b ###\n" "${color_yellow}${path}${color_less}"
|
printf " ### %b ###\n" "${color_yellow}${path}${color_less}"
|
||||||
(( flag_onlyresult )) && printf "%${config_path_width}s %s %s\n" "<INPUT>" "<EXPECTED>" "✗ [ACTUAL]"
|
(( ! flag_extendedOutput )) && printf "%${config_path_width}s %s %s\n" "<INPUT>" "<EXPECTED>" "✗ [ACTUAL]"
|
||||||
|
|
||||||
else
|
else
|
||||||
# Execute tests
|
# Execute tests
|
||||||
|
Reference in New Issue
Block a user