1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/bin/sh
# input file (jo.??.in) is a shell script; the first line must
# be a comment and is used as the name of the test:
#
# # basic logo
# $JO -a jo
#
# the expect file (jo.??.exp) is a file which will be diff'd
# against the output of the corresponding .in file:
#
# ["jo"]
#
JO="$(pwd)/jo"
TESTDIR="${0%/*}"
NTESTS=$(expr $(ls $TESTDIR/jo.??.sh 2>/dev/null | wc -l))
export JO
export TESTDIR
echo "1..$NTESTS" # Number of tests to be executed.
n=0
for t in $TESTDIR/jo.??.sh; do
n=$(expr $n + 1)
input=$t
expected="$TESTDIR/$(basename $t .sh).exp"
output=$(mktemp /tmp/jo.XXXXXX)
title=$(head -1 $input | sed -e 's/^#//')
sh $input > $output
RC=$?
if [ $RC -ne 0 ]; then
echo "not ok $n - $title"
rm -f $output
continue
fi
# if self-contained test (i.e. no 'expected' file exists)
# use the previous RC
if test -f "$expected"; then
diff "$output" "$expected" > /dev/null
RC=$?
fi
status="ok"
if [ $RC -ne 0 ]; then
status="not ok"
fi
echo "$status $n - $title"
rm -f $output
done
|