Show More
@@ -1,153 +1,159 | |||
|
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 | HGRCPATH=""; export HGRCPATH |
|
22 | 22 | |
|
23 | ECHO_N="echo -n" | |
|
24 | [ -x /usr/ucb/echo ] && ECHO_N="/usr/ucb/echo -n" | |
|
23 | if [ `echo -n HG` == "-n HG" ] | |
|
24 | then | |
|
25 | ECHO_N=echo | |
|
26 | NNL="\c" | |
|
27 | else | |
|
28 | ECHO_N="echo -n" | |
|
29 | NNL= | |
|
30 | fi | |
|
25 | 31 | |
|
26 | 32 | umask 022 |
|
27 | 33 | |
|
28 | 34 | tests=0 |
|
29 | 35 | failed=0 |
|
30 | 36 | |
|
31 | 37 | HGTMP="" |
|
32 | 38 | cleanup_exit() { |
|
33 | 39 | rm -rf "$HGTMP" |
|
34 | 40 | } |
|
35 | 41 | |
|
36 | 42 | # Remove temporary files even if we get interrupted |
|
37 | 43 | trap "cleanup_exit" 0 # normal exit |
|
38 | 44 | trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM |
|
39 | 45 | |
|
40 | 46 | HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$RANDOM.$RANDOM.$$" |
|
41 | 47 | (umask 077 && mkdir "$HGTMP") || { |
|
42 | 48 | echo "Could not create temporary directory! Exiting." 1>&2 |
|
43 | 49 | exit 1 |
|
44 | 50 | } |
|
45 | 51 | |
|
46 | 52 | TESTDIR="$PWD" |
|
47 | 53 | export TESTDIR |
|
48 | 54 | INST="$HGTMP/install" |
|
49 | 55 | PYTHONDIR="$INST/lib/python" |
|
50 | 56 | cd .. |
|
51 | 57 | if ${PYTHON-python} setup.py install --home="$INST" \ |
|
52 | 58 | --install-lib="$PYTHONDIR" > tests/install.err 2>&1 |
|
53 | 59 | then |
|
54 | 60 | rm tests/install.err |
|
55 | 61 | else |
|
56 | 62 | cat tests/install.err |
|
57 | 63 | exit 1 |
|
58 | 64 | fi |
|
59 | 65 | cd "$TESTDIR" |
|
60 | 66 | |
|
61 | 67 | BINDIR="$INST/bin" |
|
62 | 68 | PATH="$BINDIR:$PATH"; export PATH |
|
63 | 69 | if [ -n "$PYTHON" ]; then |
|
64 | 70 | { |
|
65 | 71 | echo "#!/bin/sh" |
|
66 | 72 | echo "exec \"$PYTHON"'" "$@"' |
|
67 | 73 | } > "$BINDIR/python" |
|
68 | 74 | chmod 755 "$BINDIR/python" |
|
69 | 75 | fi |
|
70 | 76 | |
|
71 | 77 | PYTHONPATH="$PYTHONDIR"; export PYTHONPATH |
|
72 | 78 | |
|
73 | 79 | run_one() { |
|
74 | 80 | rm -f "$1.err" |
|
75 | 81 | |
|
76 | 82 | mkdir "$HGTMP/$1" |
|
77 | 83 | cd "$HGTMP/$1" |
|
78 | 84 | fail=0 |
|
79 | 85 | HOME="$HGTMP/$1"; export HOME |
|
80 | 86 | OUT="$HGTMP/$1.out" |
|
81 | 87 | OUTOK="$TESTDIR/$1.out" |
|
82 | 88 | ERR="$TESTDIR/$1.err" |
|
83 | 89 | |
|
84 | 90 | if "$TESTDIR/$1" > "$OUT" 2>&1; then |
|
85 | 91 | : no error |
|
86 | 92 | else |
|
87 | 93 | echo "$1 failed with error code $?" |
|
88 | 94 | fail=1 |
|
89 | 95 | fi |
|
90 | 96 | |
|
91 | 97 | if [ -s "$OUT" -a ! -s "$OUTOK" ] ; then |
|
92 | 98 | cp "$OUT" "$ERR" |
|
93 | 99 | echo |
|
94 | 100 | echo "$1 generated unexpected output:" |
|
95 | 101 | cat "$ERR" |
|
96 | 102 | fail=1 |
|
97 | 103 | elif [ -r "$OUTOK" ]; then |
|
98 | 104 | if diff -u "$OUTOK" "$OUT" > /dev/null; then |
|
99 | 105 | : no differences |
|
100 | 106 | else |
|
101 | 107 | cp "$OUT" "$ERR" |
|
102 | 108 | echo |
|
103 | 109 | echo "$1 output changed:" |
|
104 | 110 | diff -u "$OUTOK" "$ERR" || true |
|
105 | 111 | fail=1 |
|
106 | 112 | fi |
|
107 | 113 | fi |
|
108 | 114 | |
|
109 | 115 | cd "$TESTDIR" |
|
110 | 116 | rm -f "$HGTMP/$1.out" |
|
111 | 117 | rm -rf "$HGTMP/$1" |
|
112 | 118 | return $fail |
|
113 | 119 | } |
|
114 | 120 | |
|
115 | 121 | # list of prerequisite programs |
|
116 | 122 | # stuff from coreutils (cat, rm, etc) are not tested |
|
117 | 123 | prereqs="python merge diff grep unzip gunzip bunzip2 sed" |
|
118 | 124 | missing='' |
|
119 | 125 | for pre in $prereqs ; do |
|
120 | 126 | if type $pre > /dev/null 2>&1 ; then |
|
121 | 127 | : prereq exists |
|
122 | 128 | else |
|
123 | 129 | missing="$pre $missing" |
|
124 | 130 | fi |
|
125 | 131 | done |
|
126 | 132 | |
|
127 | 133 | if [ "$missing" != '' ] ; then |
|
128 | 134 | echo "ERROR: the test suite needs some programs to execute correctly." |
|
129 | 135 | echo "The following programs are missing: " |
|
130 | 136 | for pre in $missing; do |
|
131 | 137 | echo " $pre" |
|
132 | 138 | done |
|
133 | 139 | exit 1 |
|
134 | 140 | fi |
|
135 | 141 | |
|
136 | 142 | TESTS="$*" |
|
137 | 143 | if [ -z "$TESTS" ] ; then |
|
138 | 144 | TESTS=`ls test-* | grep -v "[.~]"` |
|
139 | 145 | fi |
|
140 | 146 | |
|
141 | 147 | for f in $TESTS ; do |
|
142 | $ECHO_N "." | |
|
148 | $ECHO_N ".${NNL}" | |
|
143 | 149 | run_one $f || failed=`expr $failed + 1` |
|
144 | 150 | tests=`expr $tests + 1` |
|
145 | 151 | done |
|
146 | 152 | |
|
147 | 153 | echo |
|
148 | 154 | echo "Ran $tests tests, $failed failed." |
|
149 | 155 | |
|
150 | 156 | if [ $failed -gt 0 ] ; then |
|
151 | 157 | exit 1 |
|
152 | 158 | fi |
|
153 | 159 | exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now