]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
tests: tweak and improve tests on "Simple Tests" driver
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 23 May 2011 12:26:58 +0000 (14:26 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 23 May 2011 12:26:58 +0000 (14:26 +0200)
* tests/check.test: Make grepping of generated Makefile.in
slightly stricter.  Add trailing `:' command.
* tests/check2.test: Ensure verbose printing of captured make
output.  Make grepping of generated Makefile.in and of make
output stricter.  Add trailing `:' command.
* tests/check3.test: Likewise.  Also, fix minor error in a
comment.
* tests/check4.test: Stricter grepping of make output.  Use
`using_gmake' subroutine instead of copy&paste from defs.in
to determine whether $MAKE is GNU make.  Add a trailing `:'
command.
* tests/check6.test: Add trailing `:' command.
* tests/check10.test: Prefer redirection `>' over `>>' when
creating new files.  Ensure verbose printing of captured make
output.
* tests/check11.test: Likewise.
* tests/check7.test: Likewise.  Make grepping of make output
stricter.  Prefer "make distcheck" over a simple "make check"
in a VPATH build. Add trailing `:' command.
(a.c): Format following GNU coding standards.
(Makefile.am): Explicitly declare target `print-xfail-tests'
as PHONY.  Distribute $(check_SCRIPTS), for distcheck.
* tests/parallel-tests.test: Prefer redirection `>' over `>>'
when creating new files.
* tests/parallel-tests2.test: Likewise.
* tests/parallel-tests9.test: Likewise.
* tests/parallel-tests8.test: Likewise.  Make grepping of
automake stderr stricter.
* tests/check8.test: Likewise.  Make formatting of created
*.c files more consistent with GNU Coding Standards.
* tests/check-subst-prog.test (configure.in): Break overly
long lines.
(pass-prog.c, xfail-prog.c): Format them more consistently
with GNU Coding Standards.
* tests/parallel-tests3.test: Use a shorter and clearer skip
message.  Use the `unindent' subroutine to improve readability
of indented loop bodies.  Simplify the hack used to please
maintainer-check.
* tests/parallel-tests5.test: Make formatting of created *.c
files more consistent with GNU Coding Standards.  Use the
`unindent' subroutine to improve readability of indented loop
bodies.
* tests/parallel-tests10.test: Add blank line, for clarity.
Prefer trailing `:' over trailing `Exit 0', for consistency
with other tests.

18 files changed:
ChangeLog
tests/check-subst-prog.test
tests/check.test
tests/check10.test
tests/check11.test
tests/check2.test
tests/check3.test
tests/check4.test
tests/check6.test
tests/check7.test
tests/check8.test
tests/parallel-tests.test
tests/parallel-tests10.test
tests/parallel-tests2.test
tests/parallel-tests3.test
tests/parallel-tests5.test
tests/parallel-tests8.test
tests/parallel-tests9.test

index 39a20666941b06d68085150f030dd557351d71df..04e8921140b0bd7a8fd42571f947901a1a790dce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,52 @@
+2011-05-23  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       tests: tweak and improve tests on "Simple Tests" driver
+       * tests/check.test: Make grepping of generated Makefile.in
+       slightly stricter.  Add trailing `:' command.
+       * tests/check2.test: Ensure verbose printing of captured make
+       output.  Make grepping of generated Makefile.in and of make
+       output stricter.  Add trailing `:' command.
+       * tests/check3.test: Likewise.  Also, fix minor error in a
+       comment.
+       * tests/check4.test: Stricter grepping of make output.  Use
+       `using_gmake' subroutine instead of copy&paste from defs.in
+       to determine whether $MAKE is GNU make.  Add a trailing `:'
+       command.
+       * tests/check6.test: Add trailing `:' command.
+       * tests/check10.test: Prefer redirection `>' over `>>' when
+       creating new files.  Ensure verbose printing of captured make
+       output.
+       * tests/check11.test: Likewise.
+       * tests/check7.test: Likewise.  Make grepping of make output
+       stricter.  Prefer "make distcheck" over a simple "make check"
+       in a VPATH build. Add trailing `:' command.
+       (a.c): Format following GNU coding standards.
+       (Makefile.am): Explicitly declare target `print-xfail-tests'
+       as PHONY.  Distribute $(check_SCRIPTS), for distcheck.
+       * tests/parallel-tests.test: Prefer redirection `>' over `>>'
+       when creating new files.
+       * tests/parallel-tests2.test: Likewise.
+       * tests/parallel-tests9.test: Likewise.
+       * tests/parallel-tests8.test: Likewise.  Make grepping of
+       automake stderr stricter.
+       * tests/check8.test: Likewise.  Make formatting of created
+       *.c files more consistent with GNU Coding Standards.
+       * tests/check-subst-prog.test (configure.in): Break overly
+       long lines.
+       (pass-prog.c, xfail-prog.c): Format them more consistently
+       with GNU Coding Standards.
+       * tests/parallel-tests3.test: Use a shorter and clearer skip
+       message.  Use the `unindent' subroutine to improve readability
+       of indented loop bodies.  Simplify the hack used to please
+       maintainer-check.
+       * tests/parallel-tests5.test: Make formatting of created *.c
+       files more consistent with GNU Coding Standards.  Use the
+       `unindent' subroutine to improve readability of indented loop
+       bodies.
+       * tests/parallel-tests10.test: Add blank line, for clarity.
+       Prefer trailing `:' over trailing `Exit 0', for consistency
+       with other tests.
+
 2011-05-21  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests/README: small consistency improvement
index bda0629b22ed3f02b79b472e8888ae437766221e..b8931d5a3dfe1b15561231817b72e8b56aee81ea 100755 (executable)
@@ -22,9 +22,13 @@ required=native
 
 cat >> configure.in << 'END'
 AC_PROG_CC
-AC_SUBST([script_tests], ['subst-pass-script.test subst-xfail-script.test'])
-AC_SUBST([prog_tests], ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
-AC_SUBST([xfail_tests], ['xfail-script.test subst-xfail-script.test xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([script_tests],
+         ['subst-pass-script.test subst-xfail-script.test'])
+AC_SUBST([prog_tests],
+         ['subst-pass-prog.test$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
+AC_SUBST([xfail_tests],
+         ['xfail-script.test subst-xfail-script.test]dnl
+         [ xfail-prog$(EXEEXT) subst-xfail-prog.test$(EXEEXT)'])
 AC_OUTPUT
 END
 
@@ -48,11 +52,11 @@ cp pass-script.test subst-pass-script.test
 cp xfail-script.test subst-xfail-script.test
 
 cat > pass-prog.c <<'END'
-int main() { return 0; }
+int main (void) { return 0; }
 END
 cat > xfail-prog.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
 END
 # The .test extension is removed for the default source file name:
 cp pass-prog.c subst-pass-prog.c
index 54432eca9c590d3bf473fe3423a2b3566d38f430..2f9f8b11aa51243f4939223b1e263c874fd8b9c2 100755 (executable)
@@ -28,11 +28,13 @@ $ACLOCAL
 $AUTOMAKE
 
 grep '^check-TESTS:' Makefile.in
-grep '^check-DEJAGNU' Makefile.in && Exit 1
+grep 'check-DEJAGNU' Makefile.in && Exit 1
 
 # check-TESTS is phony.
-sed -n '/^\.PHONY:/,/^$/p' Makefile.in | grep check-TESTS
+sed -n '/^\.PHONY:/,/^$/p' Makefile.in | $EGREP '(^| )check-TESTS($| )'
 
 # check should depend directly on check-am (similar tests are
 # in check2.test and check3.test).
-grep '^check: check-am' Makefile.in
+$EGREP '^check:.* check-am( |$)' Makefile.in
+
+:
index 7025b98633939caad97949933d725d5488bad3fd..0705188c0fec2918d14d50ac7e5c4c8b5fff0bf1 100755 (executable)
@@ -27,15 +27,15 @@ TESTS = fail pass skip xfail xpass fail2 pass2 skip2 xfail2 xpass2
 XFAIL_TESTS = xfail xpass xfail2 xpass2
 END
 
-cat >>pass <<'END'
+cat > pass <<'END'
 #! /bin/sh
 exit 0
 END
-cat >>fail <<'END'
+cat > fail <<'END'
 #! /bin/sh
 exit 1
 END
-cat >>skip <<'END'
+cat > skip <<'END'
 #! /bin/sh
 exit 77
 END
@@ -69,7 +69,7 @@ $AUTOMAKE
   env TESTS='pass skip xfail' $MAKE -e check
   $MAKE check
   :
-) >stdout
+) >stdout || { cat stdout; Exit 1; }
 cat stdout
 
 grep '1 [tT]ests' stdout && Exit 1
index 912b619f1f328844a3e1a3920a7b7f0531f9f5a4..5305c96c2e1b19c396b3a1ba80256acbf800855d 100755 (executable)
@@ -26,7 +26,7 @@ cat > Makefile.am << 'END'
 TESTS = skip skip2
 END
 
-cat >>skip <<'END'
+cat > skip <<'END'
 #! /bin/sh
 exit 77
 END
@@ -38,11 +38,11 @@ $AUTOCONF
 $AUTOMAKE -a
 
 ./configure
-env TESTS=skip $MAKE -e check >stdout
+env TESTS=skip $MAKE -e check >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep '1.*passed' stdout && Exit 1
 
-env TESTS="skip skip2" $MAKE -e check >stdout
+env TESTS="skip skip2" $MAKE -e check >stdout || { cat stdout; Exit 1; }
 cat stdout
 grep '2.*passed' stdout && Exit 1
 
index 9b8bfb1b5ac2c29913942c2dc451c1343899ca10..d21551890b31106683f513c56e724844715819a1 100755 (executable)
@@ -47,16 +47,20 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
 
 # check should depend directly on check-am (similar tests are
 # in check.test and check3.test).
-grep 'check: check-recursive' Makefile.in
-grep 'check: check-am' dir/Makefile.in
+$EGREP '^check:.* check-recursive( |$)' Makefile.in
+$EGREP '^check:.* check-am( |$)' dir/Makefile.in
 
 # Make sure subrun.sh is still on its line as above.  This means Automake
 # hasn't rewritten the TESTS line unnecessarily (we can tell, because all
 # Automake variables are reformatted by VAR_PRETTY).
-grep '  subrun.sh' Makefile.in
+grep '^  subrun\.sh$' Makefile.in
+
+:
index be40e3faebc65a9baf8cadc507b2b81713ad4c44..b4f4f9d2efe758a5f39507859663a4788575f31b 100755 (executable)
@@ -56,14 +56,16 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure --prefix "`pwd`/inst"
-$MAKE check >stdout
+
+$MAKE check >stdout || { cat stdout; Exit 1; }
 cat stdout
-grep 'PASS: subrun.sh' stdout
+grep '^PASS: subrun\.sh *$' stdout
+grep 'PASS.*echo\.sh' stdout && Exit 1
 
-# check should depend directly on check-am (similar tests are
-# in check.test and check2.test).
-$FGREP 'check: $(BUILT_SOURCES)' Makefile.in
-$FGREP 'check: $(BUILT_SOURCES)' dir/Makefile.in
+# check should depend directly on $(BUILT_SOURCES) (similar tests
+# are in check.test and check2.test).
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' Makefile.in
+$EGREP '^check:.* \$\(BUILT_SOURCES\)( |$)' dir/Makefile.in
 
 $MAKE clean
 # Sanity checks
@@ -73,3 +75,5 @@ test ! -f dir/command2.inc
 $MAKE install
 test -f command1.inc
 test -f dir/command2.inc
+
+:
index 99adb23b7b4df0515566acdf87ad4b2b769f9f2f..417b2e458b8321c07fd8e5e83d9b2440c66c0b48 100755 (executable)
@@ -48,35 +48,35 @@ $ACLOCAL
 $AUTOCONF
 $AUTOMAKE
 ./configure --prefix "`pwd`/inst"
+
 $MAKE check >stdout && { cat stdout; Exit 1; }
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout && Exit 1
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout && Exit 1
 
 # The exit status of `make -k' can be anything
 # (depending on the Make implementation)
 $MAKE -k check >stdout || :
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *$' stdout
+grep '^PASS: ok\.sh *$' stdout
 
 # should also works when -k is not in first position
 $MAKE -s -k check >stdout || :
 cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+grep '^FAIL: fail\.sh *' stdout
+grep '^PASS: ok\.sh *' stdout
 
 # The rest of the test is for GNU Make.
 
-# Use --version AND -v, because SGI Make doesn't fail on --version.
-# Also grep for GNU because newer versions of FreeBSD make do
-# not complain about `--version' (they seem to silently ignore it).
-($MAKE --version -v | grep GNU) || Exit 0
+if using_gmake; then
+  # Try with a long-option that do not have a short option equivalent
+  # (here, --no-print-directory).  That should cause all options to
+  # appear verbatim in MAKEFLAGS.
+  $MAKE --no-print-directory -k check >stdout || :
+  cat stdout
+  grep '^FAIL: fail\.sh *$' stdout
+  grep '^PASS: ok\.sh *$' stdout
+fi
 
-# Try with a long-option that do not have a short option equivalent
-# (here, --no-print-directory).  That should cause all options to
-# appear verbatim in MAKEFLAGS.
-$MAKE --no-print-directory -k check >stdout || :
-cat stdout
-grep 'FAIL: fail.sh' stdout
-grep 'PASS: ok.sh' stdout
+:
index b3ba9d872c602d7d9a0523024d32074b412dd9a4..982ffbf70477b365385d94a5e2e6affcf5edc09d 100755 (executable)
@@ -50,3 +50,5 @@ mkdir build
 cd build
 ../configure
 $MAKE check
+
+:
index 5c5f4f34f327170a934ccf92501131bd6f0d5527..39c9d77dc2469f23722ef3896d001074231bb8bf 100755 (executable)
@@ -28,20 +28,25 @@ TESTS = $(XFAIL_TESTS)
 XFAIL_TESTS = a b c d
 check_PROGRAMS = a c d
 check_SCRIPTS = b
+EXTRA_DIST = $(check_SCRIPTS)
 
+.PHONY: print-xfail-tests
 print-xfail-tests:
        @echo BEG: $(XFAIL_TESTS) :END
 END
 
-cat >>b <<'END'
+cat > b <<'END'
 #! /bin/sh
 exit 1
 END
 chmod a+x b
 
-cat >>a.c <<'END'
+cat > a.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void)
+{
+  return EXIT_FAILURE;
+}
 END
 
 cp a.c c.c
@@ -53,12 +58,10 @@ $AUTOMAKE -a
 
 ./configure
 $MAKE check
-EXEEXT=.bin $MAKE -e print-xfail-tests >foo
-cat foo
-grep 'BEG: a.bin b c.bin d.bin :END' foo
+EXEEXT=.bin $MAKE -e print-xfail-tests >stdout || {  cat stdout; Exit 1; }
+cat stdout
+$FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
 
-$MAKE distclean
-mkdir build
-cd build
-../configure
-$MAKE check
+$MAKE distcheck
+
+:
index c8711e85f1a57dff2f3fc54a88e891fc984cb0ce..ae9d3752850be7bbd3ed670e1325aa8e238f8c10 100755 (executable)
@@ -34,29 +34,29 @@ END
 
 mkdir sub
 
-cat >>foo <<'END'
+cat > foo <<'END'
 #! /bin/sh
 test -f "$srcdir/Makefile.am"
 END
-cat >>sub/foo <<'END'
+cat > sub/foo <<'END'
 #! /bin/sh
 test -f "$srcdir/Makefile.am"
 END
 chmod a+x foo sub/foo
 
-cat >>bar.c <<'END'
-int main() { return 0; }
+cat > bar.c <<'END'
+int main (void) { return 0; }
 END
-cat >>sub/bar.c <<'END'
-int main() { return 0; }
+cat > sub/bar.c <<'END'
+int main (void) { return 0; }
 END
-cat >>baz.c <<'END'
+cat > baz.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
 END
-cat >>sub/baz.c <<'END'
+cat > sub/baz.c <<'END'
 #include <stdlib.h>
-int main() { return EXIT_FAILURE; }
+int main (void) { return EXIT_FAILURE; }
 END
 
 $ACLOCAL
index da961e12ab112be52056b4c142e0f8294cdb5d51..ea92ae7fafd861f56f44292e3669bd3d6caf8883 100755 (executable)
@@ -42,19 +42,19 @@ END
 # foo.test and bar.test sleep to ensure their logs are always strictly newer
 # than the logs of their prerequisites, for HP-UX make.  The quoting pleases
 # maintainer-check.
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 sleep '1'
 exit 0
 END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 sleep '1'
 exit 99
 END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
index cdf148d3528d646d01f44d185070b5d59fc3c4bf..57186111c2cfc910c0a1662f9aca142a5512200f 100755 (executable)
@@ -20,6 +20,7 @@
 
 parallel_tests=yes
 . ./defs || Exit 1
+
 cat >> configure.in << 'END'
 AC_OUTPUT
 END
@@ -43,4 +44,4 @@ $AUTOMAKE -a
 ./configure
 $MAKE check
 
-Exit 0
+:
index 8fe5d3027040cc5bd03144b85a4bf0acafd18c81..85256c8020db0bfa4d53bd6fcc6076a8dc3b1947 100755 (executable)
@@ -35,18 +35,18 @@ bla:
 CLEANFILES = bla
 END
 
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 test -f bla || exit 1
 exit 0
 END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 99
 END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
@@ -84,4 +84,5 @@ env TESTS=foo.test $MAKE -e recheck-html
 test -f bla
 test ! -f foo.log
 test -f mylog.html
+
 :
index 1d621eb122c5e001824fe7f0643e67519548e2bd..a8004e7c2172e0b952454147909707844339a839 100755 (executable)
@@ -22,7 +22,7 @@ required=GNUmake
 . ./defs || Exit 1
 
 case $MAKE in
-  *\ -j*) skip_ "this test does not work well if \$MAKE contains \`-j'";;
+  *\ -j*) skip_ "\$MAKE contains \`-j'";;
 esac
 
 cat >> configure.in << 'END'
@@ -35,13 +35,12 @@ END
 
 for i in 1 2 3 4 5 6 7 8; do
   echo "TESTS += foo$i.test" >> Makefile.am
-  cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-# hack around maintainer-check check:
-sleep='sleep '1
-$sleep
-exit 0
+  unindent >foo$i.test <<'END'
+    #! /bin/sh
+    echo "this is $0"
+    # FIXME: spurious quote to please maintainer-check
+    sleep '1'
+    exit 0
 END
   chmod a+x foo$i.test
 done
@@ -78,4 +77,5 @@ do
   $sleep
 done
 $sleep
+
 :
index 4d981c394c2bdcc4e9f350b9d76350faa7f3b5db..b1bc5b055f8812adcd96a6dcc5f56bb1ed2fb21f 100755 (executable)
@@ -41,16 +41,16 @@ END
 for i in 1 2 3 4 5 6 7 8; do
   echo "scripts += foo$i.test" >> Makefile.am
   echo "programs += foo$i.prog" >> Makefile.am
-  cat >foo$i.test <<'END'
-#! /bin/sh
-echo "this is $0"
-exit 0
+  unindent >foo$i.test <<'END'
+    #! /bin/sh
+    echo "this is $0"
+    exit 0
 END
   cat >foo$i.c <<'END'
-int main()
-{
-  return 0;
-}
+    int main (void)
+    {
+      return 0;
+    }
 END
   chmod a+x foo$i.test
 done
index d1d5b748adfb4aa1137af356f85d6471994f9a9e..84ac460cd655093c45a890ddbcfa1c99730b9670 100755 (executable)
@@ -44,7 +44,7 @@ EXTRA_DIST = foo.in foo.test
 DISTCLEANFILES = foo.test
 END
 
-cat >>foo.in <<'END'
+cat > foo.in <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 0
@@ -53,8 +53,8 @@ END
 $ACLOCAL
 $AUTOCONF
 AUTOMAKE_fails -a
-grep '(srcdir.*bar' stderr
-grep 'top_srcdir.*baz' stderr
+grep '$(srcdir).*TESTS.*bar\.test' stderr
+grep '$(top_srcdir).*TESTS.*baz\.test' stderr
 
 sed '/^TESTS +=.*srcdir/d' < Makefile.am > t
 mv -f t Makefile.am
index e6191d9224d85b0959f1033a877a97fdc147e4bc..b06d36425339b9bf641f9c7f481449cad5310968 100755 (executable)
@@ -33,18 +33,18 @@ bla:
        echo bla > $@
 END
 
-cat >>foo.test <<'END'
+cat > foo.test <<'END'
 #! /bin/sh
 echo "this is $0"
 test -f bla || exit 1
 exit 0
 END
-cat >>bar.test <<'END'
+cat > bar.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 99
 END
-cat >>baz.test <<'END'
+cat > baz.test <<'END'
 #! /bin/sh
 echo "this is $0"
 exit 1
@@ -83,4 +83,5 @@ test ! -f foo.log
 test ! -f bar.log
 test ! -f baz.log
 test -f mylog.log
+
 :