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