CDB-3094 Improves bash test runner by displaying failing tests after execution
This commit is contained in:
@@ -12,6 +12,18 @@ CMD='echo psql'
|
|||||||
CMD=psql
|
CMD=psql
|
||||||
|
|
||||||
OK=0
|
OK=0
|
||||||
|
PARTIALOK=0
|
||||||
|
|
||||||
|
function set_failed() {
|
||||||
|
OK=1
|
||||||
|
PARTIALOK=1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function clear_partial_result() {
|
||||||
|
PARTIALOK=0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sql() {
|
function sql() {
|
||||||
local ROLE
|
local ROLE
|
||||||
@@ -42,13 +54,13 @@ function sql() {
|
|||||||
if [[ "$3" != "fails" ]]
|
if [[ "$3" != "fails" ]]
|
||||||
then
|
then
|
||||||
log_error "${QUERY}"
|
log_error "${QUERY}"
|
||||||
OK=1
|
set_failed
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ "$3" == "fails" ]]
|
if [[ "$3" == "fails" ]]
|
||||||
then
|
then
|
||||||
log_error "QUERY: '${QUERY}' was expected to fail and it did not fail"
|
log_error "QUERY: '${QUERY}' was expected to fail and it did not fail"
|
||||||
OK=1
|
set_failed
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -57,7 +69,7 @@ function sql() {
|
|||||||
if [[ "${RESULT}" != "$4" ]]
|
if [[ "${RESULT}" != "$4" ]]
|
||||||
then
|
then
|
||||||
log_error "QUERY '${QUERY}' expected result '${4}' but got '${RESULT}'"
|
log_error "QUERY '${QUERY}' expected result '${4}' but got '${RESULT}'"
|
||||||
OK=1
|
set_failed
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -159,6 +171,7 @@ function tear_down() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run_tests() {
|
function run_tests() {
|
||||||
|
local FAILED_TESTS=()
|
||||||
|
|
||||||
local TESTS
|
local TESTS
|
||||||
if [[ $# -ge 1 ]]
|
if [[ $# -ge 1 ]]
|
||||||
@@ -174,10 +187,21 @@ function run_tests() {
|
|||||||
echo "# Running: ${t}"
|
echo "# Running: ${t}"
|
||||||
echo "#"
|
echo "#"
|
||||||
echo "####################################################################"
|
echo "####################################################################"
|
||||||
|
clear_partial_result
|
||||||
setup
|
setup
|
||||||
eval ${t}
|
eval ${t}
|
||||||
|
if [[ ${PARTIALOK} -ne 0 ]]
|
||||||
|
then
|
||||||
|
FAILED_TESTS+=(${t})
|
||||||
|
fi
|
||||||
tear_down
|
tear_down
|
||||||
done
|
done
|
||||||
|
if [[ ${OK} -ne 0 ]]
|
||||||
|
then
|
||||||
|
echo
|
||||||
|
log_error "The following tests are failing:"
|
||||||
|
printf -- '\t%s\n' "${FAILED_TESTS[@]}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user