Improving test report and return values

This commit is contained in:
2022-03-23 10:56:37 +01:00
parent bf303a608b
commit eb626d0f90
3 changed files with 22 additions and 7 deletions

View File

@@ -2,14 +2,23 @@
savetest() { savetest() {
local target_file= local target_file=
local environment=
local failed_tests=0
readonly savetest_dir="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" readonly savetest_dir="$(cd "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
target_dir="${savetest_dir}/results" target_dir="${savetest_dir}/results"
mkdir -p "${target_dir}" mkdir -p "${target_dir}"
target_file="${target_dir}/$("${savetest_dir}/getenv.sh")_result.log" environment="$("${savetest_dir}/getenv.sh")"
target_file="${target_dir}/${environment:-"Unknown_Environemnt"}_result.log"
"${savetest_dir}/test_rdlink.sh" >"${target_file}" 2>&1 printf "# Test environment\n\n %s\n\n" "${environment}" >"${target_file}"
"${savetest_dir}/test_rdlink.sh" -a >>"${target_file}" 2>&1
failed_tests="$?"
(( failed_tests )) && printf "Failed tests: %s\n" "$failed_tests"
return $failed_tests
} }
savetest savetest

View File

@@ -173,7 +173,7 @@ rl::test() {
done done
rl::printTestSummary $tests_success $tests_failed $tests_skipped rl::printTestSummary $tests_success $tests_failed $tests_skipped
(( testend )) && return 1 || return 0 return ${tests_failed}
} }
rl::printTitle() { rl::printTitle() {
@@ -181,7 +181,7 @@ rl::printTitle() {
flag_title=1 flag_title=1
# See if some tests will be performed # See if some tests will be performed
printf "# Testing rdlink version %s\n" "${tool_rdlink_version}" printf "# Testing rdlink version %s\n\n" "${tool_rdlink_version}"
printf " Testdate: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")" printf " Testdate: %s\n" "$(date -u +"%Y-%m-%d %H:%M:%S UTC")"
} }
@@ -273,3 +273,4 @@ rl::testcmp() {
#time rl::test "$@" #time rl::test "$@"
rl::test "$@" rl::test "$@"

View File

@@ -152,9 +152,14 @@ toassert_init() {
"../rel_b" "$(cd ".." && pwd)/rel_b" "../rel_b" "$(cd ".." && pwd)/rel_b"
) )
assert_force_fail=( "Force fail"
"nix" ""
)
# Add test arrays to global test array from test_rdlink # Add test arrays to global test array from test_rdlink
toassert+=( toassert+=(
assert_invalid_files assert_invalid_files
#assert_force_fail
) )
} }