run-tests: Print a separator when the script fails

When the script fails without running any tests, it is hard to find the
actual failure. Print a marker before the teardown starts to make it
easier to locate the last line that triggered the error.

Example marker:
===== T E A R D O W N =====

Signed-off-by: Till Maas <opensource@till.name>
This commit is contained in:
Till Maas 2019-11-07 18:52:28 +01:00
parent 5d383493f6
commit 3590ef82d3

View File

@ -147,7 +147,25 @@ function collect_artifacts {
"
}
function write_separator {
set +x
local text="$(echo "${1}" | sed 's,., \0,g') "
local char="="
local textlength=$(echo -n "${text}" | wc --chars)
local cols="$(tput cols)"
local wraplength=$(((cols - textlength) / 2))
eval printf %.1s "${char}"'{1..'"${wraplength}"\}
echo -n "${text}"
wraplength=$((wraplength + ((cols - textlength) % 2)))
eval printf %.1s "${char}"'{1..'"${wraplength}"\}
echo
set -x
}
function run_exit {
write_separator "TEARDOWN"
dump_network_info
collect_artifacts
remove_container