From 55336c5ec52641fe4a4abbb0cd113f68b7a3d888 Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Tue, 10 May 2022 19:29:35 +0000 Subject: [PATCH 1/3] Better formatting for test errors. --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 83e2e62..cc5e7c7 100755 --- a/test.sh +++ b/test.sh @@ -15,7 +15,7 @@ trap 'err_report' ERR cat "test/${PYTHON_VERSION}_unformatted.py" | python3 cblack.py -q - > test/${PYTHON_VERSION}_reformatted.py -diff test/${PYTHON_VERSION}_expected.py test/${PYTHON_VERSION}_reformatted.py +diff -u --color=auto test/${PYTHON_VERSION}_expected.py test/${PYTHON_VERSION}_reformatted.py echo "Test ${PYTHON_VERSION} Succeeded!" exit 0 From b0a17331321c9a77402e81a9fbf60981aae4a82a Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Tue, 10 May 2022 19:30:04 +0000 Subject: [PATCH 2/3] double-check python version during test this prevents errors when testing interactively --- test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test.sh b/test.sh index cc5e7c7..30091d8 100755 --- a/test.sh +++ b/test.sh @@ -13,6 +13,18 @@ err_report() { trap 'err_report' ERR +PYTHON_VERSION2="$(python3 -c 'if True: + import sys + major, minor = sys.version_info[:2] + print(major, minor, sep=".") +')" + +if [[ $PYTHON_VERSION != $PYTHON_VERSION2 ]]; then + echo >&2 \ + "wrong python version! (found $PYTHON_VERSION2 expected $PYTHON_VERSION)" \ + exit 1 +fi + cat "test/${PYTHON_VERSION}_unformatted.py" | python3 cblack.py -q - > test/${PYTHON_VERSION}_reformatted.py diff -u --color=auto test/${PYTHON_VERSION}_expected.py test/${PYTHON_VERSION}_reformatted.py From 25313258095118a889c9dcd95fe2c0c4e4e6d23a Mon Sep 17 00:00:00 2001 From: Buck Evan Date: Tue, 10 May 2022 19:30:30 +0000 Subject: [PATCH 3/3] set PUDB_TTY during test, to aid debugging maybe you don't want this, but it's nice for me and won't harm anything --- test.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 30091d8..982cffe 100755 --- a/test.sh +++ b/test.sh @@ -13,6 +13,12 @@ err_report() { trap 'err_report' ERR +if tty --quiet; then + # enable debugging with [PuDB](https://youtu.be/bJYkCWPs_UU) + export PUDB_TTY + PUDB_TTY="$(tty)" +fi + PYTHON_VERSION2="$(python3 -c 'if True: import sys major, minor = sys.version_info[:2] @@ -27,7 +33,7 @@ fi cat "test/${PYTHON_VERSION}_unformatted.py" | python3 cblack.py -q - > test/${PYTHON_VERSION}_reformatted.py -diff -u --color=auto test/${PYTHON_VERSION}_expected.py test/${PYTHON_VERSION}_reformatted.py +diff -u --color=always test/${PYTHON_VERSION}_expected.py test/${PYTHON_VERSION}_reformatted.py echo "Test ${PYTHON_VERSION} Succeeded!" exit 0