tests: Tweak the isolation wrapper for style and robustness.
Followup to c015339202
.
Suggested-by: Matthew Martin
This commit is contained in:
parent
8f19af6b31
commit
1397f1bae1
@ -114,14 +114,14 @@ run_test_internal() {
|
|||||||
|
|
||||||
run_test() {
|
run_test() {
|
||||||
# Do not combine the declaration and initialization: «local x="$(false)"» does not set $?.
|
# Do not combine the declaration and initialization: «local x="$(false)"» does not set $?.
|
||||||
local __tests_tempdir; __tests_tempdir="$(mktemp -d)"
|
local __tests_tempdir
|
||||||
if [[ $? -ne 0 ]] || [[ -z $__tests_tempdir ]] || [[ ! -d $__tests_tempdir ]]; then
|
__tests_tempdir="$(mktemp -d)" && [[ -d $__tests_tempdir ]] || {
|
||||||
echo >&2 "Bail out! mktemp failed"; return 1
|
echo >&2 "Bail out! mktemp failed"; return 1
|
||||||
fi
|
}
|
||||||
typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on
|
typeset -r __tests_tempdir # don't allow tests to override the variable that we will 'rm -rf' later on
|
||||||
|
|
||||||
{
|
{
|
||||||
run_test_internal "$__tests_tempdir" "$@"
|
(run_test_internal "$__tests_tempdir" "$@")
|
||||||
} always {
|
} always {
|
||||||
rm -rf -- "$__tests_tempdir"
|
rm -rf -- "$__tests_tempdir"
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ run_test() {
|
|||||||
# Process each test data file in test data directory.
|
# Process each test data file in test data directory.
|
||||||
integer something_failed=0
|
integer something_failed=0
|
||||||
for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
|
for data_file in ${0:h:h}/highlighters/$1/test-data/*.zsh; do
|
||||||
(run_test "$data_file") | tee >(${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 ))
|
run_test "$data_file" | tee >(${0:A:h}/tap-colorizer.zsh) | grep -v '^not ok.*# TODO' | grep -q '^not ok\|^ok.*# TODO' && (( something_failed=1 ))
|
||||||
(( $pipestatus[1] )) && exit 2
|
(( $pipestatus[1] )) && exit 2
|
||||||
done
|
done
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user