Show More
@@ -1,22 +1,23 | |||||
1 | syntax: glob |
|
1 | syntax: glob | |
2 |
|
2 | |||
3 | *.elc |
|
3 | *.elc | |
4 | *.orig |
|
4 | *.orig | |
5 | *.rej |
|
5 | *.rej | |
6 | *~ |
|
6 | *~ | |
7 | *.so |
|
7 | *.so | |
8 | *.pyc |
|
8 | *.pyc | |
9 | *.swp |
|
9 | *.swp | |
10 | *.prof |
|
10 | *.prof | |
|
11 | tests/.coverage* | |||
11 | tests/*.err |
|
12 | tests/*.err | |
12 | build |
|
13 | build | |
13 | dist |
|
14 | dist | |
14 | doc/*.[0-9] |
|
15 | doc/*.[0-9] | |
15 | doc/*.[0-9].gendoc.txt |
|
16 | doc/*.[0-9].gendoc.txt | |
16 | doc/*.[0-9].{x,ht}ml |
|
17 | doc/*.[0-9].{x,ht}ml | |
17 | MANIFEST |
|
18 | MANIFEST | |
18 | patches |
|
19 | patches | |
19 | mercurial/__version__.py |
|
20 | mercurial/__version__.py | |
20 |
|
21 | |||
21 | syntax: regexp |
|
22 | syntax: regexp | |
22 | ^\.pc/ |
|
23 | ^\.pc/ |
@@ -1,159 +1,187 | |||||
1 | #!/bin/sh -e |
|
1 | #!/bin/sh -e | |
|
2 | # | |||
|
3 | # environment variables: | |||
|
4 | # | |||
|
5 | # TEST_COVERAGE - set non-empty if you want to print test coverage report | |||
|
6 | # COVERAGE_STDLIB - set non-empty to report coverage of standard library | |||
2 |
|
7 | |||
3 | LANG="C"; export LANG |
|
8 | LANG="C"; export LANG | |
4 | LC_CTYPE="C"; export LC_CTYPE |
|
9 | LC_CTYPE="C"; export LC_CTYPE | |
5 | LC_NUMERIC="C"; export LC_NUMERIC |
|
10 | LC_NUMERIC="C"; export LC_NUMERIC | |
6 | LC_TIME="C"; export LC_TIME |
|
11 | LC_TIME="C"; export LC_TIME | |
7 | LC_COLLATE="C"; export LC_COLLATE |
|
12 | LC_COLLATE="C"; export LC_COLLATE | |
8 | LC_MONETARY="C"; export LC_MONETARY |
|
13 | LC_MONETARY="C"; export LC_MONETARY | |
9 | LC_MESSAGES="C"; export LC_MESSAGES |
|
14 | LC_MESSAGES="C"; export LC_MESSAGES | |
10 | LC_PAPER="C"; export LC_PAPER |
|
15 | LC_PAPER="C"; export LC_PAPER | |
11 | LC_NAME="C"; export LC_NAME |
|
16 | LC_NAME="C"; export LC_NAME | |
12 | LC_ADDRESS="C"; export LC_ADDRESS |
|
17 | LC_ADDRESS="C"; export LC_ADDRESS | |
13 | LC_TELEPHONE="C"; export LC_TELEPHONE |
|
18 | LC_TELEPHONE="C"; export LC_TELEPHONE | |
14 | LC_MEASUREMENT="C"; export LC_MEASUREMENT |
|
19 | LC_MEASUREMENT="C"; export LC_MEASUREMENT | |
15 | LC_IDENTIFICATION="C"; export LC_IDENTIFICATION |
|
20 | LC_IDENTIFICATION="C"; export LC_IDENTIFICATION | |
16 | LC_ALL=""; export LC_ALL |
|
21 | LC_ALL=""; export LC_ALL | |
17 | TZ=GMT; export TZ |
|
22 | TZ=GMT; export TZ | |
18 | HGEDITOR=true; export HGEDITOR |
|
23 | HGEDITOR=true; export HGEDITOR | |
19 | HGMERGE=true; export HGMERGE |
|
24 | HGMERGE=true; export HGMERGE | |
20 | HGUSER="test"; export HGUSER |
|
25 | HGUSER="test"; export HGUSER | |
21 | HGRCPATH=""; export HGRCPATH |
|
26 | HGRCPATH=""; export HGRCPATH | |
22 |
|
27 | |||
23 | if [ `echo -n HG` = "-n HG" ] |
|
28 | if [ `echo -n HG` = "-n HG" ] | |
24 | then |
|
29 | then | |
25 | ECHO_N=echo |
|
30 | ECHO_N=echo | |
26 | NNL="\c" |
|
31 | NNL="\c" | |
27 | else |
|
32 | else | |
28 | ECHO_N="echo -n" |
|
33 | ECHO_N="echo -n" | |
29 | NNL= |
|
34 | NNL= | |
30 | fi |
|
35 | fi | |
31 |
|
36 | |||
32 | umask 022 |
|
37 | umask 022 | |
33 |
|
38 | |||
34 | tests=0 |
|
39 | tests=0 | |
35 | failed=0 |
|
40 | failed=0 | |
36 |
|
41 | |||
37 | HGTMP="" |
|
42 | HGTMP="" | |
38 | cleanup_exit() { |
|
43 | cleanup_exit() { | |
39 | rm -rf "$HGTMP" |
|
44 | rm -rf "$HGTMP" | |
40 | } |
|
45 | } | |
41 |
|
46 | |||
42 | # Remove temporary files even if we get interrupted |
|
47 | # Remove temporary files even if we get interrupted | |
43 | trap "cleanup_exit" 0 # normal exit |
|
48 | trap "cleanup_exit" 0 # normal exit | |
44 | trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM |
|
49 | trap "exit 255" 1 2 3 6 15 # HUP INT QUIT ABRT TERM | |
45 |
|
50 | |||
46 | HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$RANDOM.$RANDOM.$$" |
|
51 | HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$RANDOM.$RANDOM.$$" | |
47 | (umask 077 && mkdir "$HGTMP") || { |
|
52 | (umask 077 && mkdir "$HGTMP") || { | |
48 | echo "Could not create temporary directory! Exiting." 1>&2 |
|
53 | echo "Could not create temporary directory! Exiting." 1>&2 | |
49 | exit 1 |
|
54 | exit 1 | |
50 | } |
|
55 | } | |
51 |
|
56 | |||
52 | TESTDIR="$PWD" |
|
57 | TESTDIR="$PWD" | |
53 | export TESTDIR |
|
58 | export TESTDIR | |
54 | INST="$HGTMP/install" |
|
59 | INST="$HGTMP/install" | |
55 | PYTHONDIR="$INST/lib/python" |
|
60 | PYTHONDIR="$INST/lib/python" | |
56 | cd .. |
|
61 | cd .. | |
57 | if ${PYTHON-python} setup.py install --home="$INST" \ |
|
62 | if ${PYTHON-python} setup.py install --home="$INST" \ | |
58 | --install-lib="$PYTHONDIR" > tests/install.err 2>&1 |
|
63 | --install-lib="$PYTHONDIR" > tests/install.err 2>&1 | |
59 | then |
|
64 | then | |
60 | rm tests/install.err |
|
65 | rm tests/install.err | |
61 | else |
|
66 | else | |
62 | cat tests/install.err |
|
67 | cat tests/install.err | |
63 | exit 1 |
|
68 | exit 1 | |
64 | fi |
|
69 | fi | |
65 | cd "$TESTDIR" |
|
70 | cd "$TESTDIR" | |
66 |
|
71 | |||
67 | BINDIR="$INST/bin" |
|
72 | BINDIR="$INST/bin"; export BINDIR | |
|
73 | if [ -n "$TEST_COVERAGE" ]; then | |||
|
74 | COVERAGE_FILE="$TESTDIR/.coverage"; export COVERAGE_FILE | |||
|
75 | rm -f "$COVERAGE_FILE" | |||
|
76 | mv "$BINDIR/hg" "$BINDIR/hg.py" | |||
|
77 | { | |||
|
78 | echo '#!/bin/sh' | |||
|
79 | echo "exec \"${PYTHON-python}\" \"$TESTDIR/coverage.py\"" \ | |||
|
80 | "-x \"$BINDIR/hg.py\" \"\$@\"" | |||
|
81 | } > "$BINDIR/hg" | |||
|
82 | chmod 700 "$BINDIR/hg" | |||
|
83 | fi | |||
|
84 | ||||
68 | PATH="$BINDIR:$PATH"; export PATH |
|
85 | PATH="$BINDIR:$PATH"; export PATH | |
69 | if [ -n "$PYTHON" ]; then |
|
86 | if [ -n "$PYTHON" ]; then | |
70 | { |
|
87 | { | |
71 | echo "#!/bin/sh" |
|
88 | echo "#!/bin/sh" | |
72 | echo "exec \"$PYTHON"'" "$@"' |
|
89 | echo "exec \"$PYTHON"'" "$@"' | |
73 | } > "$BINDIR/python" |
|
90 | } > "$BINDIR/python" | |
74 | chmod 755 "$BINDIR/python" |
|
91 | chmod 755 "$BINDIR/python" | |
75 | fi |
|
92 | fi | |
76 |
|
93 | |||
77 | PYTHONPATH="$PYTHONDIR"; export PYTHONPATH |
|
94 | PYTHONPATH="$PYTHONDIR"; export PYTHONPATH | |
78 |
|
95 | |||
79 | run_one() { |
|
96 | run_one() { | |
80 | rm -f "$1.err" |
|
97 | rm -f "$1.err" | |
81 |
|
98 | |||
82 | mkdir "$HGTMP/$1" |
|
99 | mkdir "$HGTMP/$1" | |
83 | cd "$HGTMP/$1" |
|
100 | cd "$HGTMP/$1" | |
84 | fail=0 |
|
101 | fail=0 | |
85 | HOME="$HGTMP/$1"; export HOME |
|
102 | HOME="$HGTMP/$1"; export HOME | |
86 | OUT="$HGTMP/$1.out" |
|
103 | OUT="$HGTMP/$1.out" | |
87 | OUTOK="$TESTDIR/$1.out" |
|
104 | OUTOK="$TESTDIR/$1.out" | |
88 | ERR="$TESTDIR/$1.err" |
|
105 | ERR="$TESTDIR/$1.err" | |
89 |
|
106 | |||
90 | if "$TESTDIR/$1" > "$OUT" 2>&1; then |
|
107 | if "$TESTDIR/$1" > "$OUT" 2>&1; then | |
91 | : no error |
|
108 | : no error | |
92 | else |
|
109 | else | |
93 | echo "$1 failed with error code $?" |
|
110 | echo "$1 failed with error code $?" | |
94 | fail=1 |
|
111 | fail=1 | |
95 | fi |
|
112 | fi | |
96 |
|
113 | |||
97 | if [ -s "$OUT" -a ! -s "$OUTOK" ] ; then |
|
114 | if [ -s "$OUT" -a ! -s "$OUTOK" ] ; then | |
98 | cp "$OUT" "$ERR" |
|
115 | cp "$OUT" "$ERR" | |
99 | echo |
|
116 | echo | |
100 | echo "$1 generated unexpected output:" |
|
117 | echo "$1 generated unexpected output:" | |
101 | cat "$ERR" |
|
118 | cat "$ERR" | |
102 | fail=1 |
|
119 | fail=1 | |
103 | elif [ -r "$OUTOK" ]; then |
|
120 | elif [ -r "$OUTOK" ]; then | |
104 | if diff -u "$OUTOK" "$OUT" > /dev/null; then |
|
121 | if diff -u "$OUTOK" "$OUT" > /dev/null; then | |
105 | : no differences |
|
122 | : no differences | |
106 | else |
|
123 | else | |
107 | cp "$OUT" "$ERR" |
|
124 | cp "$OUT" "$ERR" | |
108 | echo |
|
125 | echo | |
109 | echo "$1 output changed:" |
|
126 | echo "$1 output changed:" | |
110 | diff -u "$OUTOK" "$ERR" || true |
|
127 | diff -u "$OUTOK" "$ERR" || true | |
111 | fail=1 |
|
128 | fail=1 | |
112 | fi |
|
129 | fi | |
113 | fi |
|
130 | fi | |
114 |
|
131 | |||
115 | cd "$TESTDIR" |
|
132 | cd "$TESTDIR" | |
116 | rm -f "$HGTMP/$1.out" |
|
133 | rm -f "$HGTMP/$1.out" | |
117 | rm -rf "$HGTMP/$1" |
|
134 | rm -rf "$HGTMP/$1" | |
118 | return $fail |
|
135 | return $fail | |
119 | } |
|
136 | } | |
120 |
|
137 | |||
121 | # list of prerequisite programs |
|
138 | # list of prerequisite programs | |
122 | # stuff from coreutils (cat, rm, etc) are not tested |
|
139 | # stuff from coreutils (cat, rm, etc) are not tested | |
123 | prereqs="python merge diff grep unzip gunzip bunzip2 sed" |
|
140 | prereqs="python merge diff grep unzip gunzip bunzip2 sed" | |
124 | missing='' |
|
141 | missing='' | |
125 | for pre in $prereqs ; do |
|
142 | for pre in $prereqs ; do | |
126 | if type $pre > /dev/null 2>&1 ; then |
|
143 | if type $pre > /dev/null 2>&1 ; then | |
127 | : prereq exists |
|
144 | : prereq exists | |
128 | else |
|
145 | else | |
129 | missing="$pre $missing" |
|
146 | missing="$pre $missing" | |
130 | fi |
|
147 | fi | |
131 | done |
|
148 | done | |
132 |
|
149 | |||
133 | if [ "$missing" != '' ] ; then |
|
150 | if [ "$missing" != '' ] ; then | |
134 | echo "ERROR: the test suite needs some programs to execute correctly." |
|
151 | echo "ERROR: the test suite needs some programs to execute correctly." | |
135 | echo "The following programs are missing: " |
|
152 | echo "The following programs are missing: " | |
136 | for pre in $missing; do |
|
153 | for pre in $missing; do | |
137 | echo " $pre" |
|
154 | echo " $pre" | |
138 | done |
|
155 | done | |
139 | exit 1 |
|
156 | exit 1 | |
140 | fi |
|
157 | fi | |
141 |
|
158 | |||
142 | TESTS="$*" |
|
159 | TESTS="$*" | |
143 | if [ -z "$TESTS" ] ; then |
|
160 | if [ -z "$TESTS" ] ; then | |
144 | TESTS=`ls test-* | grep -v "[.~]"` |
|
161 | TESTS=`ls test-* | grep -v "[.~]"` | |
145 | fi |
|
162 | fi | |
146 |
|
163 | |||
147 | for f in $TESTS ; do |
|
164 | for f in $TESTS ; do | |
148 | $ECHO_N ".${NNL}" |
|
165 | $ECHO_N ".${NNL}" | |
149 | run_one $f || failed=`expr $failed + 1` |
|
166 | run_one $f || failed=`expr $failed + 1` | |
150 | tests=`expr $tests + 1` |
|
167 | tests=`expr $tests + 1` | |
151 | done |
|
168 | done | |
152 |
|
169 | |||
153 | echo |
|
170 | echo | |
154 | echo "Ran $tests tests, $failed failed." |
|
171 | echo "Ran $tests tests, $failed failed." | |
155 |
|
172 | |||
|
173 | if [ -n "$TEST_COVERAGE" ]; then | |||
|
174 | unset PYTHONPATH | |||
|
175 | $ECHO_N "$BINDIR,$TESTDIR,$HGTMP/test-," > "$HGTMP/omit" | |||
|
176 | if [ -z "$COVERAGE_STDLIB" ]; then | |||
|
177 | "${PYTHON-python}" -c 'import sys; print ",".join(sys.path)' \ | |||
|
178 | >> "$HGTMP/omit" | |||
|
179 | fi | |||
|
180 | cd "$PYTHONDIR" | |||
|
181 | "${PYTHON-python}" "$TESTDIR/coverage.py" -r --omit="`cat \"$HGTMP/omit\"`" | |||
|
182 | fi | |||
|
183 | ||||
156 | if [ $failed -gt 0 ] ; then |
|
184 | if [ $failed -gt 0 ] ; then | |
157 | exit 1 |
|
185 | exit 1 | |
158 | fi |
|
186 | fi | |
159 | exit 0 |
|
187 | exit 0 |
General Comments 0
You need to be logged in to leave comments.
Login now