* tests/self-check-me.test: Renamed ...
* tests/self-check-me.tap: .. to this, and converted to use TAP.
* tests/self-check-exit.test: Renamed ...
* tests/self-check-exit.tap: .. to this, and converted to use TAP.
Set `$stderr_fileno_' to `2', to avoid spurious messages on the
console. Add a new test, and relax another one.
* tests/self-check-env-sanitize.test: Renamed ...
* tests/self-check-env-sanitize.tap: .. to this, and converted to
the use TAP.
* tests/Makefile.am (TESTS): Update.
2011-08-09 Stefano Lattarini <stefano.lattarini@gmail.com>
+ self tests: some new uses of TAP, few extensions
+ * tests/self-check-me.test: Renamed ...
+ * tests/self-check-me.tap: .. to this, and converted to use TAP.
+ * tests/self-check-exit.test: Renamed ...
+ * tests/self-check-exit.tap: .. to this, and converted to use TAP.
+ Set `$stderr_fileno_' to `2', to avoid spurious messages on the
+ console. Add a new test, and relax another one.
+ * tests/self-check-env-sanitize.test: Renamed ...
+ * tests/self-check-env-sanitize.tap: .. to this, and converted to
+ the use TAP.
+ * tests/Makefile.am (TESTS): Update.
+
+2011-08-09 Stefano Lattarini <stefano.lattarini@gmail.com>
+
test defs: test directory creation more configurable
After this change, the individual tests will be able to tell
`./defs' whether or not to create a temporary test directory
rulepat.test \
self-check-cleanup.test \
self-check-dir.test \
-self-check-env-sanitize.test \
-self-check-exit.test \
+self-check-env-sanitize.tap \
+self-check-exit.tap \
self-check-explicit-skips.test \
self-check-is_newest.test \
-self-check-me.test \
+self-check-me.tap \
self-check-reexec.test \
self-check-report.test \
self-check-sanity.test \
rulepat.test \
self-check-cleanup.test \
self-check-dir.test \
-self-check-env-sanitize.test \
-self-check-exit.test \
+self-check-env-sanitize.tap \
+self-check-exit.tap \
self-check-explicit-skips.test \
self-check-is_newest.test \
-self-check-me.test \
+self-check-me.tap \
self-check-reexec.test \
self-check-report.test \
self-check-sanity.test \
# Make sure that the testsuite initialization code complains when
# some testsuite-influential variables are set in the environment.
-. ./defs-static || exit 1
+am_create_testdir=no
+. ./defs || Exit 1
set -x
exec 5>&1
+plan_ 16 # Two times the number of variable names in $vars.
+
vars='
me
parallel_tests
original_ACLOCAL
'
+do_run ()
+{
+ env "$1=foo" $SHELL -c '. ./defs' foo.test
+}
+
+do_grep ()
+{
+ env "$1=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
+ | grep "foo\.test:.* variable \`$1'.* in the environment.*unsafe"
+}
+
for var in $vars; do
- env "$var=foo" $SHELL -c '. ./defs' foo.test && exit 1
- env "$var=foo" $SHELL -c '. ./defs' foo.test 2>&1 1>&5 \
- | grep "foo\.test:.* variable \`$var'.* in the environment.*unsafe" \
- || exit 1
+ command_not_ok_ "$var [err status]" do_run $var
+ command_ok_ "$var [err message]" do_grep $var
done
:
# passed to the exit trap installed by the `./defs' script.
# Also check that the `errexit' shell flag is active.
-. ./defs-static || exit 99
+am_create_testdir=no
+. ./defs || Exit 99
-unset am_explicit_skips
+plan_ 34
+
+unset am_explicit_skips stderr_fileno_
AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
for st in 1 2 3 4 5 77 99 126 127 128 129 130 255; do
-
- echo "* Try: Exit $st"
- $SHELL -c ". ./defs; Exit $st; :"
- rc=$?
- echo "* rc=$rc"
- echo
- test $rc -eq $st || exit 1
-
- echo "* Try: sh -c 'exit $st'"
- $SHELL -c ". ./defs; sh -c 'exit $st'; :"
- rc=$?
- echo "* rc=$rc"
- echo
- test $rc -eq $st || exit 1
-
+ rc=0; $SHELL -c ". ./defs; Exit $st; :" || rc=$?
+ command_ok_ "Exit $st" test $rc -eq $st
+ rc=0; $SHELL -c ". ./defs; sh -c 'exit $st'; :" || rc=$?
+ command_ok_ "exit $st" test $rc -eq $st
done
-echo "* Try: non-existent-program"
-$SHELL -c ". ./defs; non-existent-program; :"
-rc=$?
-echo "* rc=$rc"
-echo
-test $rc -eq 127 || exit 1
-
for sig in 1 2 13 15; do
-
- echo "* Try: kill -$sig \$\$"
if test $sig -eq 2; then
# Some Korn shells might otherwise get a spurious SIGINT
# signal when one is sent to the child $SHELL.
trap : 2
fi
- $SHELL -c ". ./defs; kill -$sig \$\$; :"
- rc=$?
+ rc=0; $SHELL -c ". ./defs; kill -$sig \$\$; :" || rc=$?
if test $sig -eq 2; then
# Reset default SIGINT handler as portably as possible.
trap 2 || trap - 2
fi
- echo "* rc=$rc"
- echo
if test x"$sh_errexit_works" = x"yes"; then
# The exit trap should turn into an hard errors any failure
# caused by signals.
- test $rc -eq 99 || exit 1
+ command_ok_ "kill -$sig" test $rc -eq 99
else
# The exit trap is not installed, so that the shell should exit
# with status 128+n when receiving signal number n. But don't
# be too strict in the check, as POSIX only says that "The exit
# status of a command that terminated because it received a
# signal shall be reported as greater than 128".
- test $rc -gt 128 || exit 1
+ command_ok_ "kill -$sig" test $rc -gt 128
fi
done
+: Non-existent program.
+rc=0; $SHELL -c ". ./defs; non-existent-program; :" || rc=$?
+command_ok_ "command not found" test $rc -gt 0
+
+: Non-executable command.
+: > non-executable
+rc=0; $SHELL -c ". ./defs; ./non-executable; :" || rc=$?
+command_ok_ "permission denied" test $rc -gt 0
+
+: Syntax errors in the test code.
+rc=0; $SHELL -c ". ./defs; if :; then" || rc=$?
+command_ok_ "syntax error 1" test $rc -gt 0
+rc=0; $SHELL -c ". ./defs; fi" || rc=$?
+command_ok_ "syntax error 2" test $rc -gt 0
+
:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Sanity check for the automake testsuite.
+# Make sure that $me gets automatically defined by `./defs', and that it
+# can be overridden by the test script.
+
+am_create_testdir=no
+. ./defs || Exit 1
+
+plan_ 9
+
+AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
+set +e
+
+do_check ()
+{
+ if $SHELL -c '. ./defs && echo me=$me' "$1" | grep "^me=$2$"; then
+ r='ok'
+ else
+ r='not ok'
+ fi
+ result_ "$r" "me=$1"
+ unset r
+}
+
+do_check foo-bar-.test 'foo-bar-'
+do_check _foo__bar.test '_foo__bar'
+do_check 012.test '012'
+do_check foo.bar 'foo\.bar'
+do_check a.b.c.test 'a\.b\.c'
+
+# If we override $me, ./defs should not modify it.
+
+if s=`$SHELL -c 'me=foo.test && . ./defs && echo me=$me' bad.test`; then
+ r='ok'
+else
+ r='not ok'
+fi
+result_ "$r" "override of \$me before ./defs causes no error"
+
+r='ok'
+if printf '%s\n' "$s" | grep '^me=foo\.test$'; then :; else r='not ok'; fi
+if printf '%s\n' "$s" | grep 'me=bad'; then r='not ok'; else :; fi
+result_ "$r" "override of \$me before defs is honored"
+
+# Overriding $me after sourcing ./defs-static should work.
+
+if s=`$SHELL -c '. ./defs-static && me=zardoz &&
+ . ./defs && echo me=$me' bad.test`; then
+ r='ok'
+else
+ r='not ok'
+fi
+result_ "$r" "override of \$me after defs-static causes no error"
+
+r='ok'
+if printf '%s\n' "$s" | grep '^me=zardoz$'; then :; else r='not ok'; fi
+if printf '%s\n' "$s" | grep 'me=bad'; then r='not ok'; else :; fi
+result_ "$r" "override of \$me after ./defs-static is honored"
+
+:
+++ /dev/null
-#! /bin/sh
-# Copyright (C) 2011 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# Sanity check for the automake testsuite.
-# Make sure that $me gets automatically defined by `./defs', and that it
-# can be overridden by the test script.
-
-. ./defs-static || exit 1
-
-set -ex
-
-AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC
-
-$SHELL -c '. ./defs && echo me=$me' foo-bar-.test | grep '^me=foo-bar-$'
-$SHELL -c '. ./defs && echo me=$me' _foo__bar.test | grep '^me=_foo__bar$'
-$SHELL -c '. ./defs && echo me=$me' 012.test | grep '^me=012$'
-$SHELL -c '. ./defs && echo me=$me' foo.bar | grep '^me=foo\.bar$'
-$SHELL -c '. ./defs && echo me=$me' a.b.c.test | grep '^me=a\.b\.c$'
-
-# Overriding $me after sourcing ./defs-static should work.
-s=`$SHELL -c '. ./defs-static && me=zardoz && . ./defs && echo me=$me' \
- bad.test` || exit 1
-printf '%s\n' "$s" | grep '^me=zardoz$'
-printf '%s\n' "$s" | grep 'me=bad' && exit 1
-
-# If we override $me, ./defs should not modify it.
-s=`$SHELL -c 'me=foo.test && . ./defs && echo me=$me' \
- bad.test` || exit 1
-printf '%s\n' "$s" | grep '^me=foo\.test$'
-printf '%s\n' "$s" | grep 'me=bad' && exit 1
-
-: