##// END OF EJS Templates
Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein -
r804:19388dcb default
parent child Browse files
Show More
@@ -1,157 +1,137
1 1 #!/bin/sh -e
2 2
3 3 LANG="C"; export LANG
4 4 LC_CTYPE="C"; export LC_CTYPE
5 5 LC_NUMERIC="C"; export LC_NUMERIC
6 6 LC_TIME="C"; export LC_TIME
7 7 LC_COLLATE="C"; export LC_COLLATE
8 8 LC_MONETARY="C"; export LC_MONETARY
9 9 LC_MESSAGES="C"; export LC_MESSAGES
10 10 LC_PAPER="C"; export LC_PAPER
11 11 LC_NAME="C"; export LC_NAME
12 12 LC_ADDRESS="C"; export LC_ADDRESS
13 13 LC_TELEPHONE="C"; export LC_TELEPHONE
14 14 LC_MEASUREMENT="C"; export LC_MEASUREMENT
15 15 LC_IDENTIFICATION="C"; export LC_IDENTIFICATION
16 16 LC_ALL=""; export LC_ALL
17 17 TZ=GMT; export TZ
18 18 HGEDITOR=true; export HGEDITOR
19 19 HGMERGE=true; export HGMERGE
20 20 HGUSER="test"; export HGUSER
21 21
22 22 umask 022
23 23
24 if [ "$[1+1]" = "2" ]; then
25 use_arithmetic=true
26 else
27 use_arithmetic=false
28 fi
29
30 24 tests=0
31 25 failed=0
32 26
33 27 HGTMP=""
34 28 cleanup_exit() {
35 29 rm -rf "$HGTMP"
36 30 exit $1
37 31 }
38 32
39 33 # Remove temporary files even if we get interrupted
40 34 trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
41 35
42 36 HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$RANDOM.$RANDOM.$$"
43 37 (umask 077 && mkdir "$HGTMP") || {
44 38 echo "Could not create temporary directory! Exiting." 1>&2
45 39 exit 1
46 40 }
47 41
48 42 TESTDIR="$PWD"
49 43
50 44 if [ -d /usr/lib64 ]; then
51 45 lib=lib64
52 46 else
53 47 lib=lib
54 48 fi
55 49
56 50 INST="$HGTMP/install"
57 51 cd ..
58 if ${PYTHON:-python} setup.py install --home="$INST" > tests/install.err 2>&1
52 if ${PYTHON-python} setup.py install --home="$INST" > tests/install.err 2>&1
59 53 then
60 54 rm tests/install.err
61 55 mv "$INST/bin/hg" "$INST/bin/hg.real"
62 56 (
63 57 echo '#!/bin/sh'
64 58 echo 'echo "+ hg $@"'
65 59 echo 'exec hg.real "$@"'
66 60 ) > "$INST/bin/hg"
67 61 chmod 755 "$INST/bin/hg"
68 62 else
69 63 cat tests/install.err
70 64 cleanup_exit 1
71 65 fi
72 66 cd "$TESTDIR"
73 67
74 68 PATH="$INST/bin:$PATH"; export PATH
75 69 PYTHONPATH="$INST/$lib/python"; export PYTHONPATH
76 70
77 71
78 72 run_one() {
79 73 rm -f "$1.err"
80 74
81 75 mkdir "$HGTMP/$1"
82 76 cd "$HGTMP/$1"
83 77 fail=0
84 78 HOME="$HGTMP/$1"; export HOME
85 79 OUT="$HGTMP/$1.out"
86 80 OUTOK="$TESTDIR/$1.out"
87 81 ERR="$TESTDIR/$1.err"
88 82
89 83 if "$TESTDIR/$1" > "$OUT" 2>&1; then
90 84 : no error
91 85 else
92 86 echo "$1 failed with error code $?"
93 87 fail=1
94 88 fi
95 89
96 90 if [ -s "$OUT" -a ! -s "$OUTOK" ] ; then
97 91 cp "$OUT" "$ERR"
98 92 echo
99 93 echo "$1 generated unexpected output:"
100 94 cat "$ERR"
101 95 fail=1
102 96 elif [ -r "$OUTOK" ]; then
103 97 if diff -u "$OUTOK" "$OUT" > /dev/null; then
104 98 : no differences
105 99 else
106 100 if FIXME="`grep 'FIXME' \"$TESTDIR/$1\"`"; then
107 101 echo
108 102 echo "$1 failed, but this is ignored because of:"
109 103 echo "$FIXME"
110 104 else
111 105 cp "$OUT" "$ERR"
112 106 echo
113 107 echo "$1 output changed:"
114 108 diff -u "$OUTOK" "$ERR" || true
115 109 fail=1
116 110 fi
117 111 fi
118 112 fi
119 113
120 114 cd "$TESTDIR"
121 115 rm -f "$HGTMP/$1.out"
122 116 rm -rf "$HGTMP/$1"
123 117 return $fail
124 118 }
125 119
126 TESTS="$@"
120 TESTS="$*"
127 121 if [ -z "$TESTS" ] ; then
128 TESTS=`ls test-* | grep -Ev "\.|~"`
122 TESTS=`ls test-* | grep -v "[.~]"`
129 123 fi
130 124
131 125 for f in $TESTS ; do
132 126 echo -n "."
133 if $use_arithmetic; then
134 run_one $f || failed=$[$failed + 1]
135 tests=$[$tests + 1]
136 else
137 run_one $f || failed=1
138 fi
127 run_one $f || failed=`expr $failed + 1`
128 tests=`expr $tests + 1`
139 129 done
140 130
141 if $use_arithmetic; then
142 131 echo
143 132 echo "Ran $tests tests, $failed failed."
144 133
145 134 if [ $failed -gt 0 ] ; then
146 135 cleanup_exit 1
147 136 fi
148 else
149 echo
150 if [ "$failed" = "1" ] ; then
151 echo "Ran tests, at least one failed."
152 cleanup_exit 1
153 else
154 echo "Ran tests, none failed."
155 fi
156 fi
157 137 cleanup_exit 0
General Comments 0
You need to be logged in to leave comments. Login now