From 7900bd20d8ae25f929b8867b638e05a5f74f0618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Mon, 21 Nov 2016 19:06:54 +0100 Subject: 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. --- sam/commands/filter-capitalize.cmd | 2 +- sam/test.sh | 41 ++++++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 16 deletions(-) (limited to 'sam') 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 -- cgit v1.2.3