Some test suite fixes and improvements

* tests/test-lib.sh: Flag tests with missing pre-requirements as
SKIPped instead of PASSed.  Do not use GNU diff extensions, but
still require a diff that understands "-u".
* tests: Do not unnecessarily require GNU diff in a lot of tests.
Make the sed utility optional.
This commit is contained in:
Andreas Gruenbacher 2010-05-04 04:07:45 +02:00
parent 1b2ed3de07
commit dbb26b7e99
22 changed files with 45 additions and 25 deletions

View File

@ -1,5 +1,11 @@
2009-05-04 Andreas Gruenbacher <agruen@suse.de>
* tests/test-lib.sh: Flag tests with missing pre-requirements as
SKIPped instead of PASSed. Do not use GNU diff extensions, but
still require a diff that understands "-u".
* tests: Do not unnecessarily require GNU diff in a lot of tests.
Make the sed utility optional.
* src/pch.c (intuit_diff_type): Remove left-over debugging code.
* src/pch.c (maybe_reverse): Allow to create and delete empty files.

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -9,7 +9,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -7,7 +7,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -8,7 +8,8 @@
. $srcdir/test-lib.sh
require_diff
require_gnu_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -9,7 +9,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -9,7 +9,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -7,7 +7,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -9,7 +9,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -9,6 +9,7 @@
. $srcdir/test-lib.sh
require_cat
require_sed
use_local_patch
use_tmpdir

View File

@ -9,6 +9,7 @@
. $srcdir/test-lib.sh
require_cat
require_sed
use_local_patch
use_tmpdir

View File

@ -9,7 +9,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -9,7 +9,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_gnu_diff
use_local_patch
use_tmpdir

View File

@ -7,7 +7,7 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
use_local_patch
use_tmpdir

View File

@ -9,7 +9,8 @@
. $srcdir/test-lib.sh
require_cat
require_diff
require_sed
require_gnu_diff
use_local_patch
use_tmpdir

View File

@ -9,7 +9,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir

View File

@ -5,23 +5,32 @@
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.
# FIXME: Requires a version of diff that understands "-u".
require_cat() {
if ! type cat > /dev/null 2> /dev/null; then
echo "This test requires the cat utility" >&2
exit 2
exit 77
fi
}
require_diff() {
require_gnu_diff() {
case "`diff --version 2> /dev/null`" in
*GNU*)
;;
*)
echo "This test requires GNU diff" >&2
exit 2
exit 77
esac
}
require_sed() {
if ! type sed > /dev/null 2> /dev/null; then
echo "This test requires the sed utility" >&2
exit 77
fi
}
have_ed() {
type ed >/dev/null 2>/dev/null
}
@ -30,7 +39,7 @@ use_tmpdir() {
tmpdir=`mktemp -d ${TMPDIR:-/tmp}/patch.XXXXXXXXXX`
if test -z "$tmpdir" ; then
echo "This test requires the mktemp utility" >&2
exit 2
exit 77
fi
cd "$tmpdir"
}
@ -53,6 +62,17 @@ clean_env() {
VERSION_CONTROL PATCH_VERSION_CONTROL GDB
}
if type sed > /dev/null 2> /dev/null; then
eval '_beautify() {
sed -e "1s:.*:--- expected:" \
-e "2s:.*:+++ got:"
}'
else
eval '_beautify() {
cat
}'
fi
_check() {
_start_test "$@"
expected=`cat`
@ -65,7 +85,7 @@ _check() {
if test "$expected" != "$got" ; then
echo "$expected" > expected~
echo "$got" > got~
diff -u -L expected -L got expected~ got~
diff -u expected~ got~ | _beautify
rm -f expected~ got~
fi
checks_failed="$checks_failed + 1"
@ -81,12 +101,12 @@ ncheck() {
}
cleanup() {
status=$?
checks_succeeded=`expr $checks_succeeded`
checks_failed=`expr $checks_failed`
checks_total=`expr $checks_succeeded + $checks_failed`
status=0
if test $checks_total -gt 0 ; then
if test $checks_failed -gt 0 ; then
if test $checks_failed -gt 0 -a $status -eq 0 ; then
status=1
fi
echo "$checks_total tests ($checks_succeeded passed," \

View File

@ -7,7 +7,6 @@
. $srcdir/test-lib.sh
require_cat
require_diff
use_local_patch
use_tmpdir