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