better-exceptions/test_all.sh

77 lines
2.0 KiB
Bash
Raw Permalink 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
2020-12-23 04:20:19 +03:00
if [[ -z "$PYTHON" ]]; then
PYTHON=python3
fi
2017-03-24 08:10:14 +03:00
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|<module '"'[^']*' from '[^']*'>|<module 'test_module' from '/removed/for/test/purposes.py'>"'|g' | sed 's|File "/[^"]*"|File "/removed/for/test/purposes.ext"|g' | grep -v "bash: warning:"
2017-03-24 08:10:14 +03:00
}
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 {
2020-12-23 04:20:19 +03:00
test_case "$PYTHON" "test/test.py"
test_case "$PYTHON" "test/test_color.py"
test_case "$PYTHON" "test/test_encoding.py"
2017-03-24 08:10:14 +03:00
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"
2020-12-23 04:20:19 +03:00
test_case "$PYTHON" "test/test_logging.py"
test_case "$PYTHON" "test/test_truncating.py"
test_case "$PYTHON" "test/test_truncating_disabled.py"
test_case "$PYTHON" "test/test_indentation_error.py"
test_case "$PYTHON" "test/test_syntax_error.py"
test_case "$PYTHON" "test/test_unittest_patch.py"
2020-12-23 04:20:19 +03:00
if [[ "$PYTHON" == "python3" ]]; then
test_case "$PYTHON" "test/test_chaining.py"
fi
2017-03-24 08:10:14 +03:00
}
for encoding in ascii "UTF-8"; do
for term in xterm vt100 dumb; do
2017-03-24 08:10:14 +03:00
for color in 0 1; do
2020-12-23 04:20:19 +03:00
[[ $color == "1" ]] && color_filename="color" || color_filename="nocolor"
filename="test/output/python3-${term}-${encoding}-${color_filename}.out"
2017-03-24 08:10:14 +03:00
export PYTHONIOENCODING="${encoding}"
2020-12-23 04:20:19 +03:00
export TERM="${term}"
export FORCE_COLOR="${color}"
2017-03-24 08:10:14 +03:00
2020-12-23 04:20:19 +03:00
echo -e "\x1b[35;1m${filename}\x1b[m" >&2
if $GENERATE; then
exec > "$filename"
test_all "$filename"
else
test_all | diff "$(pwd)/${filename}" -
fi
2017-03-24 08:10:14 +03:00
done
done
done