run-tests.sh 2.98 KB
Newer Older
Daniel Barlow's avatar
Daniel Barlow committed
1 2
#!/bin/sh

3
# do_tests {lisp invocation} {scripts-regex}
4 5 6 7
# - read lisp forms one at a time from standard input
# - quit with exit status 0 on getting eof
# - quit with exit status >0 if an unhandled error occurs

8 9
export TEST_DIR="$PWD/tmp/"
export CL_SOURCE_REGISTRY="$TEST_DIR/dir1/:$TEST_DIR/dir2//"
10

11 12 13 14 15 16 17 18 19 20
if [ x"$1" = "xhelp" ]; then
    echo "$0 [lisp invocation] [scripts-regex]"
    echo " - read lisp forms one at a time from matching scripts"
    echo " - quit with exit status 0 on getting eof"
    echo " - quit with exit status >0 if an unhandled error occurs"
    echo " you need to supply the .script in the second argument"
    echo " lisps include sbcl, clisp, allegro and allegromodern"
    exit -1
fi

21 22 23
if [ -z "$2" ]; then
    scripts="*.script"
else
24
    scripts="$2"
25 26
fi

27 28
sok=1

29
do_tests() {
30
rm -f *.$2 || true
31 32 33 34 35 36
( cd .. && echo '(load "test/compile-asdf.lisp")' | $1  )
if [ $? -eq 0 ] ; then
    test_count=0
    test_pass=0
    test_fail=0
    failed_list=""
37
    for i in $scripts ; 
38 39 40
    do 
      echo "Testing: $i" >&2
      test_count=`expr "$test_count" + 1`
41
      rm -f *.$2 || true
42
      if  $1 < $i ; then
43 44 45 46 47 48 49 50 51 52
        echo "Using $1, $i passed" >&2
	test_pass=`expr "$test_pass" + 1`
      else
        echo "Using $1, $i failed" >&2
	test_fail=`expr "$test_fail" + 1`
	failed_list="$failed_list $i"
        sok=0
      fi
    done
    echo >&2
Gary King's avatar
Gary King committed
53
    echo "-#---------------------------------------" >&2
54 55 56 57 58 59 60 61
    echo "Using $1" >&2
    echo "Ran $test_count tests: " >&2
    echo "  $test_pass passing and $test_fail failing" >&2
    if [ $test_fail -eq 0 ] ; then
	echo "all tests apparently successful" >&2
    else
	echo "failing test(s): $failed_list" >&2
    fi
Gary King's avatar
Gary King committed
62
    echo "-#---------------------------------------" >&2
63 64
    echo >&2
fi
65 66
}

67
# terminate on error
68 69
set -e

70 71 72
lisp=$1
if [ -z $1 ] ; then
    lisp="sbcl"
73 74
fi

75 76 77
if [ "$lisp" = "sbcl" ] ; then 
    if type sbcl ; then
      fasl_ext="fasl"
Gary King's avatar
Gary King committed
78
      command="sbcl --userinit /dev/null --sysinit /dev/null --noinform --noprogrammer"
79 80 81 82
    fi
elif [ "$lisp" = "clisp" ] ; then
    if type clisp ; then
	fasl_ext="fas"
83
	command=`which clisp`
84 85 86 87 88
	command="$command -norc -ansi -I - "
    fi
elif [ "$lisp" = "allegro" ] ; then
    if type alisp ; then
	fasl_ext="fasl"
89
	command="alisp -q -batch "
90
    fi
91 92 93
elif [ "$lisp" = "allegromodern" ] ; then
    if type mlisp ; then
	fasl_ext="fasl"
94
	command="mlisp -q -batch "
95
    fi
Gary King's avatar
Gary King committed
96 97
elif [ "$lisp" = "ccl" ] ; then
    if type ccl ; then
Gary King's avatar
Gary King committed
98
	fasl_ext="dx32fsl"
Gary King's avatar
Gary King committed
99 100
	command="ccl --no-init --quiet --batch "
    fi
101 102
fi

103 104 105 106 107 108

#if [ -x /usr/bin/lisp ]
#then 
#  do_tests "/usr/bin/lisp -batch -noinit" x86f
#fi

109
create_asds () {
110 111
    mkdir -p tmp/{conf.d,dir1,dir2/{dir3,dir4}}
    for i in `find tmp | sed -e '1d;/conf.d/d'`; do touch "$i"/test.asd; done
112 113 114 115 116 117
}

clean_up () {
    rm -rf tmp
}

118 119

if [ -z "$command" ] ; then
Gary King's avatar
Gary King committed
120
    echo "Error: cannot find or do not know how to run Lisp named $lisp"
121
else
Gary King's avatar
Gary King committed
122
    mkdir -p results
123
    echo $command
Gary King's avatar
Gary King committed
124 125
    thedate=`date "+%Y-%m-%d"`
    do_tests "$command" $fasl_ext 2>&1 | tee "results/${lisp}.text" "results/${lisp}-${thedate}.save"
126
fi
127