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