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