ngx-fancyindex/t/run

58 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

#! /bin/bash
set -e
if [[ $# -lt 1 || $# -gt 2 ]] ; then
echo "Usage: $0 <prefix-path> [1]" 1>&2
exit 1
fi
readonly T=$(dirname "$0")
export T
readonly prefix=$1
dynamic=false
if [[ $# -gt 1 && $2 -eq 1 ]] ; then
dynamic=true
fi
readonly dynamic
declare -a t_pass=( )
declare -a t_fail=( )
for t in "$T"/*.test ; do
name="t/${t##*/}"
name=${name%.test}
printf "${name} ... "
errfile="${name}.err"
outfile="${name}.out"
shfile="${name}.sh"
cat > "${shfile}" <<-EOF
readonly PREFIX='${prefix}'
readonly DYNAMIC=${dynamic}
$(< "$T/preamble")
$(< "$t")
EOF
if bash -e "${shfile}" > "${outfile}" 2> "${errfile}" ; then
t_pass+=( "${name}" )
printf 'passed\n'
else
t_fail+=( "${name}" )
printf 'failed\n'
fi
done
for name in "${t_fail[@]}" ; do
printf '=== %s.out ===\n' "${name}"
cat "${name}.out"
printf '=== %s.err ===\n' "${name}"
cat "${name}.err"
done
printf '=== passed/failed/total: %d/%d/%d ===\n' \
${#t_pass[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} ))
if [[ ${#t_fail[@]} -gt 0 ]] ; then
exit 1
fi