#!/bin/bash # OTTER_JST_VERBOSE=1 set -e self=jstest/run1 src="${0%/$self}" fail () { echo >&2 "$self: error: $*"; exit 1; } [ "x$src/$self" = "x$0" ] || fail "mismatch $src/$self $0" t=${1##*/} t=${t%%.*} tmp=tmp/js-$t rm -rf $tmp mkdir -p $tmp cd $tmp ln -s ../../target/jstest/otter_wasm{.js,_bg.wasm} . export NODE_PATH=. ln -sf "$@" . if grep '^\/\/ @expect' $1; then sed -n <$1 ' /^\/\/ @@expect/,/^\/\/ @@end/ { s/^\/\/ //; /^@@/d; p; } ' >expect else rm -f expect fi wrap=$(sed -n 's/^\/\/ @@wrap //p' $1) case "$wrap" in '') ;; */*) fail "uh $wrap" ;; *) wrap=../../target/debug/$wrap esac exec 3>run.js sed >&3 &3 $t.nodejs exec 3>&- set +e $wrap nodejs run.js >output rc=$? set -e if [ $rc != 0 ] || [ "$OTTER_JST_VERBOSE" ]; then cat output ||: fi if test -f expect; then diff -u expect output fi exit $rc