annotate tests/run-tests @ 362:410373162036

run-tests: run tests given on the command line -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 run-tests: run tests given on the command line manifest hash: e0217e478de902d0de7b9a294509718365f1d837 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsL7EywK+sNU5EO8RAiGJAJ92ZB/+N8+XnOt717cuADK9ajQ+lwCfW1LG 02mjQ04uoS0n+D8xi0KX9tM= =d1lZ -----END PGP SIGNATURE-----
author mpm@selenic.com
date Wed, 15 Jun 2005 15:50:28 -0800
parents b4e0e20646bb
children 37249c522770
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
1 #!/bin/bash
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
2
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
3 set -e
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
4
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
5 tests=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
6 failed=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
7 H=$PWD
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
8
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
9 function run_one
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
10 {
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
11 D=`mktemp -d`
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
12 if [ "$D" == "" ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
13 echo mktemp failed!
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
14 fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
15
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
16 cd $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
17 fail=0
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
18
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
19 if ! $H/$f > .out 2>&1 ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
20 echo $f failed with error code $?
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
21 fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
22 fi
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
23
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
24 if [ -s .out -a ! -r $H/$f.out ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
25 echo $f generated unexpected output:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
26 cat .out
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
27 cp .out $H/$f.err
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
28 fail=1
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
29 elif [ -r $H/$f.out ] && ! diff -u $H/$f.out .out > /dev/null ; then
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
30 echo $f output changed:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
31 diff -u $H/$f.out .out && true
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
32 cp .out $H/$f.err
341
c0deea64ce64 run-tests: actually mark changed output as failure
mpm@selenic.com
parents: 331
diff changeset
33 fail=1
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
34 fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
35
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
36 cd $H
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
37 rm -r $D
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
38 return $fail
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
39 }
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
40
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
41 TESTS=$@
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
42 if [ "$TESTS" == "" ] ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
43 TESTS=`ls test-* | grep -Ev "\.|~"`
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
44 fi
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
45
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
46 for f in $TESTS ; do
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
47 echo -n "."
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
48 if ! run_one $f ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
49 failed=$[$failed + 1]
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
50 fi
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
51 tests=$[$tests + 1]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
52 done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
53
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
54 echo
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
55 echo Ran $tests tests, $failed failed
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
56
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
57 if [ $failed -gt 0 ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
58 exit 1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
59 fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
60