run-tests 704 Bytes
Newer Older
Niels Möller's avatar
Niels Möller committed
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
#! /bin/sh

failed=0
all=0

function env_program () {
  if [ -x ./"$1" ] ; then
    if ./"$1" then : ; else
      echo FAIL: $1
      exit 1
    fi
  fi

function test_program () {
  if $1 ; then
    echo PASS: ${$1%-test}
  else
    echo FAIL: ${$1%-test}
    failed=`expr $failed + 1`
  fi
  all=`expr $all + 1`
}

env_program setup-env

if [ $# -eq 0 ] ; then
  for f in *-test; do test_program $1; done
else
  for f in "$@" ; then do test_program $1; done
fi

if [ $failed -eq 0 ] ; then
  banner="All $all tests passed"
else
  banner="$failed of $all tests failed"
fi
dashes=`echo "$banner" | sed s/./=/g`
echo "$dashes"
echo "$banner"
echo "$dashes"

env_program teardown-env

[ "$failed" -eq 0 ]