[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-712-
From: |
Stefano Lattarini |
Subject: |
[Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-712-g082028c |
Date: |
Mon, 28 Feb 2011 12:36:35 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Automake".
http://git.sv.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=082028c1dbb8e23e3a7b32ebaa3d92321b55cb15
The branch, master has been updated
via 082028c1dbb8e23e3a7b32ebaa3d92321b55cb15 (commit)
from fd22dca159cfa10ecbb822d0dd6cc677cf333aab (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 082028c1dbb8e23e3a7b32ebaa3d92321b55cb15
Author: Stefano Lattarini <address@hidden>
Date: Mon Feb 21 14:57:24 2011 +0100
tests: add testcases sanity-checking the testsuite
Helper subroutines, variables and other pieces of code defined
in the `tests/defs' and used by many testcases are non-obvious,
and tricky to get to work portably; but until now, they weren't
tested at all in a clear and self-contained way.
This change should remedy to the situation.
* tests/self-check-cleanup.test: New test, check removal of
temporary test working directory by `./defs'.
* tests/self-check-dir.test: New test, check that tests using
`./defs' create a proper temporary directory, and run in it.
* tests/self-check-exit.test: New test, check that, in case of
failing commands, the correct exit status is passed to the exit
trap installed by the `./defs' script.
* tests/self-check-is_newest.test: New test, checking the
`is_newest' subroutine.
* tests/self-check-me.test: New test, checking that $me gets
defined automatically by `tests/defs' if not set, and that it
can be overridden from either the shell or the environment.
* tests/self-check-sanity.test: New test, check that the sanity
checks performed by the `tests/defs' script works correctly.
* tests/self-check-unindent.test: New test, checking the
`unindent' subroutine.
* tests/Makefile.am (TESTS): Update.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 26 +++
tests/Makefile.am | 7 +
tests/Makefile.in | 7 +
tests/self-check-cleanup.test | 129 ++++++++++++
tests/{help-python.test => self-check-dir.test} | 30 ++--
tests/self-check-exit.test | 80 +++++++
...{help-python.test => self-check-is_newest.test} | 29 ++-
tests/{help-python.test => self-check-me.test} | 24 +--
tests/self-check-sanity.test | 69 ++++++
tests/self-check-unindent.test | 217 ++++++++++++++++++++
10 files changed, 575 insertions(+), 43 deletions(-)
create mode 100755 tests/self-check-cleanup.test
copy tests/{help-python.test => self-check-dir.test} (64%)
create mode 100755 tests/self-check-exit.test
copy tests/{help-python.test => self-check-is_newest.test} (70%)
copy tests/{help-python.test => self-check-me.test} (62%)
create mode 100755 tests/self-check-sanity.test
create mode 100755 tests/self-check-unindent.test
diff --git a/ChangeLog b/ChangeLog
index f1adebc..5ef0c0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2011-02-25 Stefano Lattarini <address@hidden>
+
+ tests: add testcases sanity-checking the testsuite
+ Helper subroutines, variables and other pieces of code defined
+ in the `tests/defs' and used by many testcases are non-obvious,
+ and tricky to get to work portably; but until now, they weren't
+ tested at all in a clear and self-contained way.
+ This change should remedy to the situation.
+ * tests/self-check-cleanup.test: New test, check removal of
+ temporary test working directory by `./defs'.
+ * tests/self-check-dir.test: New test, check that tests using
+ `./defs' create a proper temporary directory, and run in it.
+ * tests/self-check-exit.test: New test, check that, in case of
+ failing commands, the correct exit status is passed to the exit
+ trap installed by the `./defs' script.
+ * tests/self-check-is_newest.test: New test, checking the
+ `is_newest' subroutine.
+ * tests/self-check-me.test: New test, checking that $me gets
+ defined automatically by `tests/defs' if not set, and that it
+ can be overridden from either the shell or the environment.
+ * tests/self-check-sanity.test: New test, check that the sanity
+ checks performed by the `tests/defs' script works correctly.
+ * tests/self-check-unindent.test: New test, checking the
+ `unindent' subroutine.
+ * tests/Makefile.am (TESTS): Update.
+
2011-02-20 Stefano Lattarini <address@hidden>
tests: tempdirs with restrictive permissions are cleaned correctly
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3709d47..e808917 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -788,6 +788,13 @@ reqd.test \
reqd2.test \
repeated-options.test \
rulepat.test \
+self-check-cleanup.test \
+self-check-dir.test \
+self-check-exit.test \
+self-check-is_newest.test \
+self-check-me.test \
+self-check-sanity.test \
+self-check-unindent.test \
sanity.test \
scripts.test \
seenc.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 68db8b5..451dff5 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1050,6 +1050,13 @@ reqd.test \
reqd2.test \
repeated-options.test \
rulepat.test \
+self-check-cleanup.test \
+self-check-dir.test \
+self-check-exit.test \
+self-check-is_newest.test \
+self-check-me.test \
+self-check-sanity.test \
+self-check-unindent.test \
sanity.test \
scripts.test \
seenc.test \
diff --git a/tests/self-check-cleanup.test b/tests/self-check-cleanup.test
new file mode 100755
index 0000000..92a203e
--- /dev/null
+++ b/tests/self-check-cleanup.test
@@ -0,0 +1,129 @@
+#! /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.
+# Check creation/removal of temporary test working directory by `./defs'.
+
+. ./defs || Exit 1
+
+if test x"$sh_errexit_works" != x"yes"; then
+ echo "$me: the shell can't have a working exit trap with 'set -e'" >&2
+ Exit 77
+fi
+
+# We still need a little hack to make ./defs work outside automake's
+# tree `tests' subdirectory. Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+cp ../defs .
+
+have_symlinks=false
+ln -s defs foo && have_symlinks=:
+export have_symlinks # Is used also by spawned shells.
+
+dir=dummy.dir
+
+# Check that pre-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+mkdir $dir $dir/sub
+cd $dir
+touch file sub/file
+if $have_symlinks; then
+ ln -s file symlink
+ ln -s none brokenlink
+fi
+cd ..
+chmod 000 $dir/sub/* $dir/file $dir/symlink
+chmod 000 $dir/sub $dir
+$SHELL -c '. ./defs' dummy.test
+test ! -f $dir
+test ! -d $dir
+test ! -r $dir
+
+# Check that post-test cleanup works also with directories with
+# "null" permissions, and containing broken symlinks.
+$SHELL -c '
+ . ./defs || Exit 1
+ set -e
+ mkdir dir dir/sub
+ cd dir
+ touch file sub/file
+ if $have_symlinks; then
+ ln -s file symlink
+ ln -s none brokenlink
+ fi
+ cd ..
+ chmod 000 dir/sub/* dir/file dir/symlink
+ chmod 000 dir/sub dir
+' dummy.test
+test ! -f $dir
+test ! -d $dir
+test ! -r $dir
+
+# Check that pre-test cleanup does not unduly change the permissions of
+# files to which symlinks in the temporary test directory point to.
+if $have_symlinks; then
+
+ mkdir dir
+ chmod 000 dir
+ : > file
+ chmod 000 file
+
+ mkdir $dir
+ cd $dir
+ ln -s ../dir ../file .
+ cd ..
+ $SHELL -c '. ./defs' dummy.test
+ ls -l # For debugging.
+ ls -l file | grep "^---------- .*file"
+ ls -ld dir | grep "^d--------- .*dir"
+
+ $SHELL -c '
+ ocwd=`pwd` || exit 1
+ . ./defs || Exit 1
+ ln -s "$ocwd/dir" "$ocwd/file" .
+ ' dummy.test
+ ls -l # For debugging.
+ ls -l file | grep "^---------- .*file"
+ ls -ld dir | grep "^d--------- .*dir"
+
+ rmdir dir
+ rm -f file
+
+fi # $have_symlinks
+
+# Check that the cleanup trap does not remove the temporary
+# test directory in case of test failure, skip, hard-error,
+# or when receiving a signal.
+for bailout_command in \
+ 'Exit 1' \
+ 'Exit 2' \
+ 'Exit 10' \
+ 'Exit 77' \
+ 'Exit 99' \
+ 'Exit 126' \
+ 'Exit 127' \
+ 'Exit 255' \
+ 'kill -1 $$' \
+ 'kill -2 $$' \
+ 'kill -9 $$' \
+ 'kill -13 $$' \
+ 'kill -15 $$' \
+; do
+ $SHELL -c ". ./defs; : > foo; $bailout_command" dummy.test && Exit 1
+ test -f dummy.dir/foo
+done
+
+:
diff --git a/tests/help-python.test b/tests/self-check-dir.test
similarity index 64%
copy from tests/help-python.test
copy to tests/self-check-dir.test
index ba20013..a8e5d88 100755
--- a/tests/help-python.test
+++ b/tests/self-check-dir.test
@@ -14,24 +14,24 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Make sure that macro `AM_PATH_PYTHON' adds proper text to the
-# configure help screen.
+# Sanity check for the automake testsuite.
+# Check that tests using `./defs' create a proper temporary directory,
+# and run in it.
-. ./defs || Exit 1
+set -ex
-set -e
+this=S_dir
+outcome=:
+pwd
-cat > configure.in <<END
-AC_INIT([$me], [1.0])
-AM_PATH_PYTHON
-END
+rm -f $this.tmp
-$ACLOCAL
-$AUTOCONF
+$SHELL -c "
+ . ./defs || Exit 1
+ : > $this.tmp
+ case \`pwd\` in '`pwd`'/$this.dir);; *) Exit 1;; esac
+" $this.test || outcome=false
-./configure --help >stdout || { cat stdout; Exit 1; }
-cat stdout
+test -f $this.tmp && { rm -f $this.tmp; outcome=false; }
-grep '^ *PYTHON *the Python interpreter$' stdout
-
-:
+$outcome
diff --git a/tests/self-check-exit.test b/tests/self-check-exit.test
new file mode 100755
index 0000000..73f3ea5
--- /dev/null
+++ b/tests/self-check-exit.test
@@ -0,0 +1,80 @@
+#! /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.
+# Check that. in case of failing commands, the correct exit status is
+# passed to the exit trap installed by the `./defs' script.
+# Also check that the `errexit' shell flag is active.
+
+. ./defs-static || exit 99
+
+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
+
+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=$?
+ 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
+ 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
+ fi
+
+done
+
+:
diff --git a/tests/help-python.test b/tests/self-check-is_newest.test
similarity index 70%
copy from tests/help-python.test
copy to tests/self-check-is_newest.test
index ba20013..f179229 100755
--- a/tests/help-python.test
+++ b/tests/self-check-is_newest.test
@@ -14,24 +14,29 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Make sure that macro `AM_PATH_PYTHON' adds proper text to the
-# configure help screen.
+# Sanity check for the automake testsuite.
+# Check the `is_newest' subroutine.
. ./defs || Exit 1
-set -e
+: > a
+$sleep
+: > b
+: > c
-cat > configure.in <<END
-AC_INIT([$me], [1.0])
-AM_PATH_PYTHON
-END
+stat a b c || : # for debugging
-$ACLOCAL
-$AUTOCONF
+is_newest c a
+is_newest b a
+is_newest a b && Exit 1
+is_newest c b
+is_newest c c
+is_newest c a b c
-./configure --help >stdout || { cat stdout; Exit 1; }
-cat stdout
+touch -r c d
-grep '^ *PYTHON *the Python interpreter$' stdout
+stat c d || : # for debugging
+
+is_newest c d
:
diff --git a/tests/help-python.test b/tests/self-check-me.test
similarity index 62%
copy from tests/help-python.test
copy to tests/self-check-me.test
index ba20013..5773e2c 100755
--- a/tests/help-python.test
+++ b/tests/self-check-me.test
@@ -14,24 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# Make sure that macro `AM_PATH_PYTHON' adds proper text to the
-# configure help screen.
+# Sanity check for the automake testsuite.
+# Make sure that $me gets automatically defined by `./defs'.
-. ./defs || Exit 1
+set -ex
-set -e
+: ${SHELL=/bin/sh}
-cat > configure.in <<END
-AC_INIT([$me], [1.0])
-AM_PATH_PYTHON
-END
-
-$ACLOCAL
-$AUTOCONF
-
-./configure --help >stdout || { cat stdout; Exit 1; }
-cat stdout
-
-grep '^ *PYTHON *the Python interpreter$' stdout
+$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$'
:
diff --git a/tests/self-check-sanity.test b/tests/self-check-sanity.test
new file mode 100755
index 0000000..d35432f
--- /dev/null
+++ b/tests/self-check-sanity.test
@@ -0,0 +1,69 @@
+#! /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.
+# Test the sanity checks performed by the `defs' script. Also check
+# that we can use `defs' elsewhere, when we duplicate some of the
+# infrastructure from the automake/tests subdirectory.
+
+. ./defs || Exit 1
+
+# Avoid to confuse traces from child processed with our own traces.
+show_stderr ()
+{
+ sed 's/^/ | /' stderr >&2
+}
+
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'defs-static: not found in current directory' stderr
+fi
+
+sed 's|^testsrcdir=.*|testsrcdir=foo|' ../defs-static > defs-static
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'foo/defs-static\.in not found.*check \$testsrcdir' stderr
+fi
+
+sed 's|^testbuilddir=.*|testbuilddir=foo|' ../defs-static > defs-static
+if $SHELL -c '. ../defs' dummy.test 2>stderr; then
+ show_stderr
+ Exit 1
+else
+ show_stderr
+ grep 'foo/defs-static not found.*check \$testbuilddir' stderr
+fi
+
+# We still need a little hack to make ./defs work outside automake's
+# tree `tests' subdirectory. Not a big deal.
+sed "s|^testbuilddir=.*|testbuilddir='`pwd`'|" ../defs-static >defs-static
+# Redefining *srcdir and *builddir variables in the environment shouldn't
+# cause problems
+env \
+ builddir=bad-dir srcdir=bad-dir \
+ top_builddir=bad-dir top_srcdir=bad-dir \
+ abs_builddir=bad-dir abs_srcdir=bad-dir \
+ abs_top_builddir=bad-dir abs_top_srcdir=bad-dir \
+ $SHELL -c '. ../defs && echo "!OK!" > ../foo' dummy.test
+$FGREP '!OK!' foo
+
+:
diff --git a/tests/self-check-unindent.test b/tests/self-check-unindent.test
new file mode 100755
index 0000000..4672683
--- /dev/null
+++ b/tests/self-check-unindent.test
@@ -0,0 +1,217 @@
+#! /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.
+# Check the `unindent' subroutine.
+
+. ./defs || Exit 1
+
+#------------------------------------------------------------------
+
+: Leading spaces
+
+cat > input <<END
+ 1
+ 2
+3
+ 4
+${tab}5
+${tab} 6
+ 6${sp}
+7${sp}
+ 8${sp}${sp}
+9${sp}${sp}
+ 10${tab}
+11${tab}
+ 12${sp}${tab}
+13${sp}${tab}
+ 14 this${tab}with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+${sp}${sp}
+${sp}
+${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+${tab}5
+${tab} 6
+6${sp}
+7${sp}
+8${sp}${sp}
+9${sp}${sp}
+10${tab}
+11${tab}
+12${sp}${tab}
+13${sp}${tab}
+14 this${tab}with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${tab}
+
+last line
+END
+
+unindent input > got
+
+diff exp got
+
+#------------------------------------------------------------------
+
+: Leading tab
+
+cat > input <<END
+${tab}1
+${tab} 2
+3
+ 4
+ 5
+ 6
+ 7
+ ${tab}8
+${tab}${tab}9
+${tab}10${tab}
+${tab}11${sp}
+12${tab}
+13${sp}
+${tab}14 this with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+${tab}
+${sp}
+${sp}${tab}
+
+last line
+END
+
+cat > exp <<END
+1
+ 2
+3
+ 4
+ 5
+ 6
+ 7
+ ${tab}8
+${tab}9
+10${tab}
+11${sp}
+12${tab}
+13${sp}
+14 this with${tab}multiple fields${sp}
+15 and ${tab}${tab}this too${tab}
+ 16 and also this
+
+${sp}
+${sp}${tab}
+
+last line
+END
+
+unindent input > got
+
+diff exp got
+
+#------------------------------------------------------------------
+
+: No leading whitespace
+
+cat > input <<END
+1
+ 2
+ 3
+ 4
+${tab}5
+${tab} 6
+ ${tab}7
+${tab}${tab}8
+9${sp}
+ 10${tab}
+${tab}10${sp}${sp}
+14 this with${tab}multiple fields${sp}
+ 15 and this too${tab}
+${tab}16 and also this
+${tab}
+${sp}
+
+last line
+END
+
+cp input exp
+
+unindent input > got
+
+diff exp got
+
+#------------------------------------------------------------------
+
+: Leading empty lines are ignored [1]
+
+cat > input <<END
+
+
+ foo
+ bar
+ quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+ quux
+END
+
+unindent input > got
+
+diff exp got
+
+#------------------------------------------------------------------
+
+: Leading empty lines are ignored [2]
+
+cat > input <<END
+
+
+foo
+bar
+ quux
+END
+
+cat > exp <<END
+
+
+foo
+bar
+ quux
+END
+
+unindent input > got
+
+diff exp got
+
+#------------------------------------------------------------------
+
+:
hooks/post-receive
--
GNU Automake
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Automake-commit] [SCM] GNU Automake branch, master, updated. v1.11-712-g082028c,
Stefano Lattarini <=