summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-07-22 13:42:53 -0700
committerMitchell Hashimoto <mitchell.hashimoto@gmail.com>2022-07-22 13:42:53 -0700
commit180d4a3c4147167ad7f76738223760c67b0ac9ae (patch)
treeac651b6733493c43047eb18b314b09e1a83af78d /test
parentd672bedec725f7167507f35cfadfbd1146280c6e (diff)
test: colorize output
Diffstat (limited to 'test')
-rwxr-xr-xtest/run.sh28
1 files changed, 14 insertions, 14 deletions
diff --git a/test/run.sh b/test/run.sh
index c504b658c..e4ccd60fc 100755
--- a/test/run.sh
+++ b/test/run.sh
@@ -16,6 +16,14 @@ function has_func() {
return $?
}
+# Colors
+export BOLD="\\e[1m"
+export RED="\\e[1;31m"
+export GREEN="\\e[1;32m"
+export YELLOW="\\e[1;33m"
+export WHITE="\\e[1;37m"
+export RESET="\\e[0;39m"
+
#--------------------------------------------------------------------
# Flag parsing
@@ -61,9 +69,6 @@ if ! has_func "test_do"; then
exit 1
fi
-echo "Term: ${ARG_EXEC}"
-echo "Case: ${ARG_CASE}"
-
# NOTE: This is a huge hack right now.
if [ "$ARG_EXEC" = "ghostty" ]; then
ARG_EXEC="/src/ghostty";
@@ -95,40 +100,35 @@ EOF
#--------------------------------------------------------------------
+printf "${RESET}${BOLD}[$(basename $ARG_EXEC)]${RESET} $ARG_CASE ... ${RESET}"
+
# Start up the program under test by launching i3. We use i3 so we can
# more carefully control the window settings, test resizing, etc.
WM_LOG="${XDG_BASE_DIR}/wm.log"
i3 -c ${XDG_BASE_DIR}/i3.cfg >${WM_LOG} 2>&1 &
-echo
-echo "Started window manager..."
-
# Wait for startup
# TODO: we can probably use xdotool or wmctrl or something to detect if any
# windows actually launched and make error handling here better.
sleep 2
# Run our test case (should be defined in test case file)
-echo "Executing test case..."
test_do
# Sleep a second to let it render
sleep 1
-echo "Capturing screen shot..."
import -window root ${ARG_OUT}
-echo "Comparing results..."
DIFF=$(compare -metric AE ${ARG_OUT} ${GOLDEN_OUT} null: 2>&1)
if [ $? -eq 2 ] ; then
- echo " Comparison failed (error)"
+ printf "${RED}ERROR${RESET}\n"
exit 1
else
- echo " Diff: ${DIFF}"
if [ $DIFF -gt 0 ]; then
- echo " Diff is too high. Failure."
+ printf "${RED}Fail (Diff: ${WHITE}${DIFF}${RED})${RESET}\n"
exit 1
+ else
+ printf "${GREEN}Pass (Diff: ${WHITE}${DIFF}${GREEN})${RESET}\n"
fi
fi
-
-echo "Done"