aboutsummaryrefslogtreecommitdiff
path: root/sam
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-21 19:06:54 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-21 19:13:58 +0100
commit7900bd20d8ae25f929b8867b638e05a5f74f0618 (patch)
treeb1a17283df09f9bef06354db5aeba35be90018a1 /sam
parent181578b452ba8643bc1e9c754acf60d51761fc99 (diff)
downloadvis-7900bd20d8ae25f929b8867b638e05a5f74f0618.tar.gz
vis-7900bd20d8ae25f929b8867b638e05a5f74f0618.tar.xz
test/sam: use our own implementation of ssam(1)
The ssam(1) rc script is seamingly not part of earlier 9base packages and the homebrew version is by default unusable due to a broken shebang line. Also improve sam(1) detection: check default binary location as used by the Debian package.
Diffstat (limited to 'sam')
-rw-r--r--sam/commands/filter-capitalize.cmd2
-rwxr-xr-xsam/test.sh41
2 files changed, 27 insertions, 16 deletions
diff --git a/sam/commands/filter-capitalize.cmd b/sam/commands/filter-capitalize.cmd
index ca9d989..78ef691 100644
--- a/sam/commands/filter-capitalize.cmd
+++ b/sam/commands/filter-capitalize.cmd
@@ -1 +1 @@
-,x/[a-zA-Z]+/ | tr a-z A-Z \ No newline at end of file
+,x/[a-zA-Z]+/ | tr a-z A-Z
diff --git a/sam/test.sh b/sam/test.sh
index 8864d9c..0a50879 100755
--- a/sam/test.sh
+++ b/sam/test.sh
@@ -2,21 +2,26 @@
NL='
'
-PLAN9="/usr/local/plan9/bin"
[ -z "$VIS" ] && VIS="../../vis"
+[ -z "$SAM" ] && SAM="sam"
+[ -z "$PLAN9" ] && PLAN9="/usr/local/plan9/bin"
-if [ -z "$SSAM" ] || ! type "$SSAM" >/dev/null 2>&1; then
- SSAM="$PLAN9/ssam"
- if ! type "$SSAM" >/dev/null 2>&1; then
- if type 9 >/dev/null 2>&1; then
- SSAM="9 ssam"
- else
- echo "ssam(1) not found, skipping tests"
- exit 0
- fi
+for SAM in "$SAM" "$PLAN9/sam" /usr/lib/plan9/bin/sam 9; do
+ if type "$SAM" >/dev/null 2>&1; then
+ break
fi
-fi
+done
+
+type "$SAM" >/dev/null 2>&1 || {
+ echo "sam(1) not found, skipping tests"
+ exit 0
+}
+
+[ "$SAM" = "9" ] && SAM="9 sam"
+
+echo "$SAM"
+$VIS -v
TESTS=$1
[ -z "$TESTS" ] && TESTS=$(find . -name '*.cmd' | sed 's/\.cmd$//g')
@@ -24,9 +29,6 @@ TESTS=$1
TESTS_RUN=0
TESTS_OK=0
-echo "$SSAM"
-$VIS -v
-
for t in $TESTS; do
IN="$t.in"
CMD="$(cat $t.cmd)"
@@ -37,7 +39,16 @@ for t in $TESTS; do
REF="$t.ref"
rm -f "$SAM_OUT" "$SAM_ERR" "$VIS_OUT" "$VIS_ERR"
printf "Running test %s with sam ... " "$t"
- cat "$IN" | PATH="$PLAN9:$PATH" $SSAM "$CMD" > "$SAM_OUT"
+
+ {
+ echo ',{'
+ echo k
+ echo '}'
+ echo 0k
+ cat "$t.cmd"
+ echo ,
+ } | $SAM -d "$IN" > "$SAM_OUT" 2>/dev/null
+
if [ $? -ne 0 ]; then
printf "ERROR\n"
elif [ -e "$REF" ]; then