This commit is contained in:
vxclutch
2026-05-03 12:24:22 -04:00
parent 95f7a7a769
commit cf1ff9a96e
6 changed files with 143 additions and 14 deletions

7
t/basic Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/sh
. t/lib.sh
check "" "tcpl: Hello, World!"
check "foo" "tcpl: Hello, foo!"
check "oo" "tcpl: Hello, foo!"

55
t/lib.sh Normal file → Executable file
View File

@@ -0,0 +1,55 @@
#!/bin/sh
scriptversion="1"
me=$(basename "$0")
version="$me/vxc v$scriptversion
Copyright (C) 2026 vxc.
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law."
usage="Usage: $me [OPTION]... <arg1> <arg2>
Does a thing
Options:
--help print this help and exit
--version output version information"
while [ $# -gt 0 ]; do
case $1 in
--help) echo "$usage"; exit 0 ;;
--version) echo "$version"; exit 0 ;;
-*) echo "$me: Unknown option '$1'." >&2; exit 1 ;;
*) break ;;
esac
shift
done
width=$(tput cols 2>/dev/null || echo 80)
INFO="\e[0;34m"
RESET="\e[0m"
OK="\e[0;32m"
BAD="\e[0;31m"
good() {
printf "%$((${width}))s\r%s...\n" "$(echo -e "$INFO[ ${OK}ok $INFO]$RESET")" "$1"
}
fail() {
printf "%$((${width}))s\r%s...\n" "$(echo -e "$INFO[${BAD}fail$INFO]$RESET")" "$1"
}
make -s
check() {
expected=$2
output=$(./tcpl $1) || { fail "$1 (execution failed)"; return 1; }
if [ "$output" = "$expected" ]; then
good "./tcpl $1"
return 0
else
fail "./tcpl $1: unexpected: $output; wanted: $expected"
return 1
fi
}