Debian Codegraph @

tests/run-test

raw symbols SCIP
1 #!/bin/sh
2 # Test runner
3 # Assumption is that this is run in the top-level directory
4 # If an executable is not specified via the -x option, it defaults to be
5 # src/angband.
6
7 usage() {
8 echo "Usage: $0 [-x executable] <test>"
9 }
10
11 run() {
12 rm -rf ~/.angband/Test
13
14 test="$1"
15 exe="$2"
16 printf "Running: $test... "
17 $exe -mtest < "$test/input" > "$test/run.out"
18 if [ -x "$test/matcher" ]; then
19 "$test/matcher" "$test"
20 else
21 diff "$test/run.out" "$test/output" >/dev/null 2>/dev/null
22 fi
23 result=$?
24 if [ $result -eq 0 ]; then
25 printf "\033[01;32mPassed\033[00m\n"
26 else
27 printf "\033[01;31mFailed\033[00m\n"
28 fi
29 return $result
30 }
31
32 argexe=src/angband
33 if test $# -gt 0 ; then
34 if test x"$1" = x-x ; then
35 shift
36 if test $# -ge 1 ; then
37 argexe="$1"
38 shift
39 else
40 usage
41 exit 1
42 fi
43 fi
44 fi
45 if test $# -eq 1 ; then
46 argtest="$1"
47 else
48 usage
49 exit 1
50 fi
51
52 run "$argtest" "$argexe"