better-exceptions/test_all.sh

66 lines
1.5 KiB
Bash
Raw Normal View History

2017-03-24 08:10:14 +03:00
#!/usr/bin/env bash
set -e
if [[ "${1}" == "generate" ]]; then
rm -rf test/output
mkdir -p test/output
GENERATE=true
else
GENERATE=false
fi
cd "$(dirname "${0}")"
PYTHONPATH="$(pwd):$(pwd)/test"
export PYTHONPATH
function normalize {
# we translate anything that looks like an address into 0xDEADBEEF
# since the addresses change from run to run and break diff testing
cat | sed 's|0x[a-fA-F0-9]\{1,\}|0xDEADBEEF|g' | sed 's|File "/[^"]*"|File "/removed/for/test/purposes.ext"|g' | grep -v "bash: warning:"
}
function test_case {
echo -e "\x1b[36;1m " "$@" "\x1b[m" 1>&2
echo "$@"
echo -e "\n"
("$@" 2>&1 || true) | normalize
echo -e "\n\n"
return $?
}
function test_all {
test_case "$BETEXC_PYTHON" "test/test.py"
test_case "$BETEXC_PYTHON" "test/test_color.py"
test_case "./test/test_interactive.sh"
# test_case "./test/test_interactive_raw.sh"
2017-03-24 08:10:14 +03:00
test_case "./test/test_string.sh"
}
for encoding in ascii "UTF-8"; do
for term in "$TERM" vt100 dumb; do
for color in 0 1; do
for pv in 2 3; do
[[ $color == "1" ]] && color_filename="color" || color_filename="nocolor"
filename="test/output/python${pv}-${term}-${encoding}-${color_filename}.out"
export LANG="en_US.${encoding}"
export LC_ALL="${LANG}"
export TERM="${term}"
export FORCE_COLOR="${color}"
export BETEXC_PYTHON="python${pv}"
echo -e "\x1b[35;1m${filename}\x1b[m" >&2
if $GENERATE; then
exec > "$filename"
test_all "$filename"
else
test_all | diff "$(pwd)/${filename}" -
fi
done
done
done
done