From 230bd5c2fd11f6256e1ab16c2e5997a8d8228461 Mon Sep 17 00:00:00 2001 From: "Jason St. John" Date: Fri, 8 Nov 2013 00:44:40 -0500 Subject: Fix whitespace and other formatting issues This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John --- test/scripts/human_to_size_test.sh | 54 +++++++++++++++++------------------ test/scripts/parseopts_test.sh | 58 +++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 56 deletions(-) (limited to 'test/scripts') diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh index a467f27e..cde3ba82 100755 --- a/test/scripts/human_to_size_test.sh +++ b/test/scripts/human_to_size_test.sh @@ -5,43 +5,43 @@ declare -i testcount=0 fail=0 pass=0 total=15 # source the library function lib=${1:-${PMTEST_SCRIPTLIB_DIR}human_to_size.sh} if [[ -z $lib || ! -f $lib ]]; then - echo "Bail out! human_to_size library ($lib) could not be located\n" - exit 1 + echo "Bail out! human_to_size library ($lib) could not be located\n" + exit 1 fi . "$lib" if ! type -t human_to_size &>/dev/null; then - printf 'Bail out! human_to_size function not found\n' - exit 1 + printf "Bail out! human_to_size function not found\n" + exit 1 fi parse_hts() { - local input=$1 expected=$2 result - - (( ++testcount )) - - result=$(human_to_size "$1") - if [[ $result = "$expected" ]]; then - (( ++pass )) - printf "ok %d - %s\n" "$testcount" "$input" - else - (( ++fail )) - printf "not ok %d - %s\n" "$testcount" "$input" - printf '# [TEST %3s]: FAIL\n' "$testcount" - printf '# input: %s\n' "$input" - printf '# output: %s\n' "$result" - printf '# expected: %s\n' "$expected" - fi + local input=$1 expected=$2 result + + (( ++testcount )) + + result=$(human_to_size "$1") + if [[ $result = "$expected" ]]; then + (( ++pass )) + printf "ok %d - %s\n" "$testcount" "$input" + else + (( ++fail )) + printf "not ok %d - %s\n" "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount" + printf '# input: %s\n' "$input" + printf '# output: %s\n' "$result" + printf '# expected: %s\n' "$expected" + fi } summarize() { - if (( !fail )); then - printf '# All %s tests successful\n\n' "$testcount" - exit 0 - else - printf '# %s of %s tests failed\n\n' "$fail" "$testcount" - exit 1 - fi + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi } trap 'summarize' EXIT diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh index 00bdbd85..2c055b1b 100755 --- a/test/scripts/parseopts_test.sh +++ b/test/scripts/parseopts_test.sh @@ -5,14 +5,14 @@ declare -i testcount=0 pass=0 fail=0 total=25 # source the library function lib=${1:-${PMTEST_SCRIPTLIB_DIR}parseopts.sh} if [[ -z $lib || ! -f $lib ]]; then - printf "Bail out! parseopts library ($lib) could not be located\n" - exit 1 + printf "Bail out! parseopts library ($lib) could not be located\n" + exit 1 fi . "$lib" if ! type -t parseopts &>/dev/null; then - printf 'Bail out! parseopts function not found\n' - exit 1 + printf "Bail out! parseopts function not found\n" + exit 1 fi # borrow opts from makepkg @@ -24,38 +24,38 @@ OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean:' 'cleanall' 'nodeps' 'noconfirm' 'noprogressbar') parse() { - local result=$1 tokencount=$2; shift 2 + local result=$1 tokencount=$2; shift 2 - (( ++testcount )) - parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null - test_result "$result" "$tokencount" "$*" "${OPTRET[@]}" - unset OPTRET + (( ++testcount )) + parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null + test_result "$result" "$tokencount" "$*" "${OPTRET[@]}" + unset OPTRET } test_result() { - local result=$1 tokencount=$2 input=$3; shift 3 - - if [[ $result = "$*" ]] && (( tokencount == $# )); then - (( ++pass )) - printf 'ok %d - %s\n' "$testcount" "$input" - else - printf 'not ok %d - %s\n' "$testcount" "$input" - printf '# [TEST %3s]: FAIL\n' "$testcount" - printf '# input: %s\n' "$input" - printf '# output: %s (%s tokens)\n' "$*" "$#" - printf '# expected: %s (%s tokens)\n' "$result" "$tokencount" - (( ++fail )) - fi + local result=$1 tokencount=$2 input=$3; shift 3 + + if [[ $result = "$*" ]] && (( tokencount == $# )); then + (( ++pass )) + printf 'ok %d - %s\n' "$testcount" "$input" + else + printf 'not ok %d - %s\n' "$testcount" "$input" + printf '# [TEST %3s]: FAIL\n' "$testcount" + printf '# input: %s\n' "$input" + printf '# output: %s (%s tokens)\n' "$*" "$#" + printf '# expected: %s (%s tokens)\n' "$result" "$tokencount" + (( ++fail )) + fi } summarize() { - if (( !fail )); then - printf '# All %s tests successful\n\n' "$testcount" - exit 0 - else - printf '# %s of %s tests failed\n\n' "$fail" "$testcount" - exit 1 - fi + if (( !fail )); then + printf '# All %s tests successful\n\n' "$testcount" + exit 0 + else + printf '# %s of %s tests failed\n\n' "$fail" "$testcount" + exit 1 + fi } trap 'summarize' EXIT -- cgit v1.2.3-70-g09d2