run-tests: bugfix on mktemp
Thomas Arendsen Hein
thomas at intevation.de
Fri Jul 29 20:56:12 UTC 2005
* Aron Griffis <agriffis at gentoo.org> [20050729 22:22]:
> Thomas Arendsen Hein wrote: [Fri Jul 29 2005, 11:07:05AM EDT]
> > +if ${PYTHON:-python} setup.py install --home="$INST" > tests/install.err 2>&1
>
> Since you changed earlier instances of :- to -, you probably intended
> to do the same here.
Sure, changed.
> > +TESTS="$@"
>
> You want "$*" here.
I want this completely different, but for now "$*" is better.
> > TESTS=`ls test-* | grep -Ev "\.|~"`
>
> grep -E isn't portable, so you probably want to switch to egrep
> (more portable) or use grep -v '[.~]' (most portable)
I saw this, but forgot to change it, thanks.
> Rather than $use_arithmetic, you could simply switch to expr:
My shell experience seems to get rusty ... it seems as if I'm too
much dependent on bash or python today.
> Instead of explicitly calling cleanup_exit everywhere, you might
> consider using trap:
>
> cleanup() {
> rm -rf "$HGTMP"
> }
>
> # 0 = normal exit (preserves exit status)
> # 1 = SIGHUP, 2 = SIGINT, 15 = SIGTERM
> trap cleanup 0 1 2 15
How do I cleanly get the feature that HUP/INT/TERM return a non-zero
error code?
And from your example it seems that the currently used
trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
isn't compatible everywhere.
Attached are the pullable patches for some of these issues.
Thomas
--
Email: thomas at intevation.de
http://intevation.de/~thomas/
-------------- next part --------------
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID 3d47e7fc33a36debf0e8e5ad5cd235a919b8e1f1
# Parent 69db1e34378b5e62fed6f4223303b722f80c6e6f
Use tabs instead of spaces where apropriate.
diff -r 69db1e34378b5e62fed6f4223303b722f80c6e6f -r 3d47e7fc33a36debf0e8e5ad5cd235a919b8e1f1 tests/run-tests
--- a/tests/run-tests Fri Jul 29 14:59:10 2005
+++ b/tests/run-tests Fri Jul 29 20:34:41 2005
@@ -60,9 +60,9 @@
rm tests/install.err
mv "$INST/bin/hg" "$INST/bin/hg.real"
(
- echo '#!/bin/sh'
- echo 'echo "+ hg $@"'
- echo 'exec hg.real "$@"'
+ echo '#!/bin/sh'
+ echo 'echo "+ hg $@"'
+ echo 'exec hg.real "$@"'
) > "$INST/bin/hg"
chmod 755 "$INST/bin/hg"
else
@@ -87,7 +87,7 @@
ERR="$TESTDIR/$1.err"
if "$TESTDIR/$1" > "$OUT" 2>&1; then
- : no error
+ : no error
else
echo "$1 failed with error code $?"
fail=1
@@ -100,21 +100,21 @@
cat "$ERR"
fail=1
elif [ -r "$OUTOK" ]; then
- if diff -u "$OUTOK" "$OUT" > /dev/null; then
- : no differences
- else
- if FIXME="`grep 'FIXME' \"$TESTDIR/$1\"`"; then
- echo
- echo "$1 failed, but this is ignored because of:"
- echo "$FIXME"
- else
- cp "$OUT" "$ERR"
- echo
- echo "$1 output changed:"
- diff -u "$OUTOK" "$ERR" || true
- fail=1
- fi
- fi
+ if diff -u "$OUTOK" "$OUT" > /dev/null; then
+ : no differences
+ else
+ if FIXME="`grep 'FIXME' \"$TESTDIR/$1\"`"; then
+ echo
+ echo "$1 failed, but this is ignored because of:"
+ echo "$FIXME"
+ else
+ cp "$OUT" "$ERR"
+ echo
+ echo "$1 output changed:"
+ diff -u "$OUTOK" "$ERR" || true
+ fail=1
+ fi
+ fi
fi
cd "$TESTDIR"
-------------- next part --------------
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID 19388dcbac4952067ac0e925bcca97ec9675c62d
# Parent 3d47e7fc33a36debf0e8e5ad5cd235a919b8e1f1
Incorporated most of Aron Griffis suggestions for sh compatibility.
diff -r 3d47e7fc33a36debf0e8e5ad5cd235a919b8e1f1 -r 19388dcbac4952067ac0e925bcca97ec9675c62d tests/run-tests
--- a/tests/run-tests Fri Jul 29 20:34:41 2005
+++ b/tests/run-tests Fri Jul 29 20:50:05 2005
@@ -20,12 +20,6 @@
HGUSER="test"; export HGUSER
umask 022
-
-if [ "$[1+1]" = "2" ]; then
- use_arithmetic=true
-else
- use_arithmetic=false
-fi
tests=0
failed=0
@@ -55,7 +49,7 @@
INST="$HGTMP/install"
cd ..
-if ${PYTHON:-python} setup.py install --home="$INST" > tests/install.err 2>&1
+if ${PYTHON-python} setup.py install --home="$INST" > tests/install.err 2>&1
then
rm tests/install.err
mv "$INST/bin/hg" "$INST/bin/hg.real"
@@ -123,35 +117,21 @@
return $fail
}
-TESTS="$@"
+TESTS="$*"
if [ -z "$TESTS" ] ; then
- TESTS=`ls test-* | grep -Ev "\.|~"`
+ TESTS=`ls test-* | grep -v "[.~]"`
fi
for f in $TESTS ; do
echo -n "."
- if $use_arithmetic; then
- run_one $f || failed=$[$failed + 1]
- tests=$[$tests + 1]
- else
- run_one $f || failed=1
- fi
+ run_one $f || failed=`expr $failed + 1`
+ tests=`expr $tests + 1`
done
-if $use_arithmetic; then
- echo
- echo "Ran $tests tests, $failed failed."
+echo
+echo "Ran $tests tests, $failed failed."
- if [ $failed -gt 0 ] ; then
- cleanup_exit 1
- fi
-else
- echo
- if [ "$failed" = "1" ] ; then
- echo "Ran tests, at least one failed."
- cleanup_exit 1
- else
- echo "Ran tests, none failed."
- fi
+if [ $failed -gt 0 ] ; then
+ cleanup_exit 1
fi
cleanup_exit 0
More information about the Mercurial
mailing list