From c92e890ce35a5f8bbdebf47aab38ee7c0b8daa66 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Sun, 27 Jun 2010 16:34:42 +0200 Subject: [PATCH] Modernize, improve and extend tests `subobj*.test'. * tests/subobjname.test: Add trailing `:' command. * tests/subobj.test: Make grepping of `Makefile.in' stricter. Escape literal dots in grep regexps. * tests/subobj2.test: Add trailing `:' command. Do not use the unportable fgrep option `-e'. * tests/subobj3.test: Add trailing `:' command. (configure.in): Use proper m4 quoting, and avoid obsolescent constructs. * tests/subobj8.test: Likewise. Also, enable `errexit' shell flag, with related changes * tests/subobj4.test: Likewise. Also, make grepping of `Makefile.in' stricter. * tests/subobj5.test: Add trailing `:' command. Move setting of `errexit' shell flag earlier in the script (just after inclusion of ./defs). (configure.in): Use the stub created by `./defs', rather than writing it from scratch, and avoid obsolescent constructs. * tests/subobj6.test: Add trailing `:' command. Move setting of `errexit' shell flag earlier in the script (just after inclusion of ./defs). Do not create useless dummy ac-init file `f'. * tests/subobj7.test: Do not create useless dummy ac-init file `f'. (configure.in): Use the stub created by `./defs', rather than writing it from scratch, and avoid obsolescent constructs. * tests/subobj9.test: Move setting of `errexit' shell flag earlier in the script (just after inclusion of ./defs). Fail the test if `make distcheck' fails. Ensure verbose printing of captured make stdout. Avoid uselsss fork by doing simple grep instead of using test -n "`COMMAND | grep ...`". (configure.in): Normalize the call to AC_INIT w.r.t. other tests. (Makefile.am): Explicitly mark target "print" as phony. * tests/subobj10.test: Removed duplicated call to `set -e'. Add trailing `:' command. (configure.in): Normalize the call to AC_INIT w.r.t. other tests. --- ChangeLog | 36 ++++++++++++++++++++++++++++++++++++ tests/subobj.test | 4 ++-- tests/subobj10.test | 8 ++++---- tests/subobj2.test | 6 ++++-- tests/subobj3.test | 17 ++++++++++------- tests/subobj4.test | 15 ++++++++++----- tests/subobj5.test | 17 ++++++++++------- tests/subobj6.test | 12 ++++++------ tests/subobj7.test | 8 +++----- tests/subobj8.test | 27 ++++++++++++++++----------- tests/subobj9.test | 23 ++++++++++++----------- tests/subobjname.test | 4 +++- 12 files changed, 116 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50407bb6d..56f62b498 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,41 @@ 2010-08-08 Stefano Lattarini + Modernize, improve and extend tests `subobj*.test'. + * tests/subobjname.test: Add trailing `:' command. + * tests/subobj.test: Make grepping of `Makefile.in' stricter. + Escape literal dots in grep regexps. + * tests/subobj2.test: Add trailing `:' command. Do not use the + unportable fgrep option `-e'. + * tests/subobj3.test: Add trailing `:' command. + (configure.in): Use proper m4 quoting, and avoid obsolescent + constructs. + * tests/subobj8.test: Likewise. Also, enable `errexit' shell + flag, with related changes + * tests/subobj4.test: Likewise. Also, make grepping of + `Makefile.in' stricter. + * tests/subobj5.test: Add trailing `:' command. Move setting of + `errexit' shell flag earlier in the script (just after inclusion + of ./defs). + (configure.in): Use the stub created by `./defs', rather than + writing it from scratch, and avoid obsolescent constructs. + * tests/subobj6.test: Add trailing `:' command. Move setting of + `errexit' shell flag earlier in the script (just after inclusion + of ./defs). Do not create useless dummy ac-init file `f'. + * tests/subobj7.test: Do not create useless dummy ac-init file + `f'. + (configure.in): Use the stub created by `./defs', rather than + writing it from scratch, and avoid obsolescent constructs. + * tests/subobj9.test: Move setting of `errexit' shell flag earlier + in the script (just after inclusion of ./defs). Fail the test if + `make distcheck' fails. Ensure verbose printing of captured make + stdout. Avoid uselsss fork by doing simple grep instead of using + test -n "`COMMAND | grep ...`". + (configure.in): Normalize the call to AC_INIT w.r.t. other tests. + (Makefile.am): Explicitly mark target "print" as phony. + * tests/subobj10.test: Removed duplicated call to `set -e'. Add + trailing `:' command. + (configure.in): Normalize the call to AC_INIT w.r.t. other tests. + Remove a couple of obsoleted tests. * tests/fpinstall.test: Removed. * tests/fpinst2.test: Likewise. diff --git a/tests/subobj.test b/tests/subobj.test index 64edd0ed4..39dc1b9ac 100755 --- a/tests/subobj.test +++ b/tests/subobj.test @@ -39,10 +39,10 @@ cat stderr >&2 grep 'install.*compile' stderr test -f compile -$FGREP 'generic/a.$(OBJEXT)' Makefile.in +grep '^generic/a\.\$(OBJEXT):' Makefile.in grep '[^/]a\.\$(OBJEXT)' Makefile.in && Exit 1 # Opportunistically test for a different bug. -grep '^generic/b.\$(OBJEXT):.*dirstamp' Makefile.in +grep '^generic/b\.\$(OBJEXT):.*dirstamp' Makefile.in : diff --git a/tests/subobj10.test b/tests/subobj10.test index a589e457b..dbddf29c1 100755 --- a/tests/subobj10.test +++ b/tests/subobj10.test @@ -21,8 +21,8 @@ required=gcc # avoid compiler errors. set -e -cat > configure.in << 'END' -AC_INIT(x, 0, x) +cat > configure.in << END +AC_INIT([$me], [1.0]) AM_INIT_AUTOMAKE([subdir-objects]) AM_PROG_AS @@ -45,8 +45,6 @@ mkdir src : >src/c.s : >d.s -set -e - $ACLOCAL $AUTOCONF $AUTOMAKE -a @@ -54,3 +52,5 @@ $AUTOMAKE -a ./configure $MAKE $MAKE distcheck + +: diff --git a/tests/subobj2.test b/tests/subobj2.test index 1282f8086..87a467140 100755 --- a/tests/subobj2.test +++ b/tests/subobj2.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 1999, 2001, 2002, 2010 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 @@ -35,4 +35,6 @@ $AUTOMAKE $FGREP 'generic/a.$(OBJEXT)' Makefile.in grep '[^/]a\.\$(OBJEXT)' Makefile.in && Exit 1 -$FGREP -e '-c -o' Makefile.in +grep '.*-c -o' Makefile.in + +: diff --git a/tests/subobj3.test b/tests/subobj3.test index a4ba765d5..4fe685c3c 100755 --- a/tests/subobj3.test +++ b/tests/subobj3.test @@ -1,6 +1,6 @@ #! /bin/sh -# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software -# Foundation, Inc. +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2010 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 @@ -22,16 +22,17 @@ required=gcc set -e -cat > configure.in << 'END' -AC_INIT(sub/hello.c) +cat > configure.in << END +AC_INIT([$me], [1.0]) dnl Prevent automake from looking in .. and ../.. -AC_CONFIG_AUX_DIR(.) -AM_INIT_AUTOMAKE(hello,0.23) +AC_CONFIG_AUX_DIR([.]) +AM_INIT_AUTOMAKE AC_PROG_CC AC_PROG_CC_STDC AM_PROG_CC_C_O AM_C_PROTOTYPES -AC_OUTPUT(Makefile) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT END cat > Makefile.am << 'END' @@ -63,3 +64,5 @@ $AUTOMAKE -a ./configure ANSI2KNR=./ansi2knr U=_ $MAKE -e ./hello + +: diff --git a/tests/subobj4.test b/tests/subobj4.test index f98ae5b19..ead2305c3 100755 --- a/tests/subobj4.test +++ b/tests/subobj4.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2004, 2010 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 @@ -19,11 +19,14 @@ . ./defs || Exit 1 +set -e + cat >> configure.in << 'END' AC_PROG_CC AM_PROG_CC_C_O AC_PROG_CXX -AC_OUTPUT(d1/Makefile d2/Makefile) +AC_CONFIG_FILES([d1/Makefile d2/Makefile]) +AC_OUTPUT END mkdir d1 d2 @@ -43,7 +46,9 @@ END : > compile : > d2/z.c -$ACLOCAL || Exit 1 -$AUTOMAKE || Exit 1 +$ACLOCAL +$AUTOMAKE + +grep '\$(CC) .*\.\./d2/z\.c' d1/Makefile.in -grep 'CC.*z' d1/Makefile.in +: diff --git a/tests/subobj5.test b/tests/subobj5.test index 9c9568ae3..c857e7393 100755 --- a/tests/subobj5.test +++ b/tests/subobj5.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2004, 2010 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 @@ -19,12 +19,13 @@ . ./defs || Exit 1 -cat > configure.in << 'END' -AC_INIT(generic/a.c) -AM_INIT_AUTOMAKE(nonesuch, nonesuch) +set -e + +cat >> configure.in << 'END' +AC_CONFIG_FILES([generic/Makefile]) AC_PROG_CC AM_PROG_CC_C_O -AC_OUTPUT(Makefile generic/Makefile) +AC_OUTPUT END cat > Makefile.am << 'END' @@ -36,10 +37,12 @@ mkdir generic : > generic/a.c : > generic/Makefile.am -set -e - $ACLOCAL $AUTOCONF $AUTOMAKE --include-deps --copy --add-missing + ./configure + $MAKE dist + +: diff --git a/tests/subobj6.test b/tests/subobj6.test index 42b6e14b9..228a1e974 100755 --- a/tests/subobj6.test +++ b/tests/subobj6.test @@ -1,5 +1,6 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2010 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 @@ -20,6 +21,8 @@ required=gcc . ./defs || Exit 1 +set -e + cat >> configure.in << 'END' AM_PROG_CC_C_O AC_OUTPUT @@ -38,9 +41,6 @@ test-distclean: distclean test ! -f generic/$(am__dirstamp) END -# The ac-init file. -: > f - mkdir generic cat > generic/a.c << 'END' #include @@ -51,8 +51,6 @@ int main () } END -set -e - $ACLOCAL $AUTOCONF $AUTOMAKE --include-deps --copy --add-missing @@ -86,3 +84,5 @@ cd build2 ../configure $MAKE $MAKE mostlyclean + +: diff --git a/tests/subobj7.test b/tests/subobj7.test index d77670c34..dd1a8febd 100755 --- a/tests/subobj7.test +++ b/tests/subobj7.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002, 2004 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2004, 2010 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 @@ -21,12 +21,10 @@ set -e -cat > configure.in << 'END' -AC_INIT(f) -AM_INIT_AUTOMAKE(nonesuch, nonesuch) +cat >> configure.in << 'END' AC_PROG_CC AM_PROG_CC_C_O -AC_OUTPUT(Makefile) +AC_OUTPUT END cat > Makefile.am << 'END' diff --git a/tests/subobj8.test b/tests/subobj8.test index 63a02d18d..ae9b09bf9 100755 --- a/tests/subobj8.test +++ b/tests/subobj8.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001, 2002 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2010 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 @@ -18,13 +18,16 @@ . ./defs || Exit 1 -cat > configure.in << 'END' -AC_INIT(Makefile.am) -AC_CONFIG_AUX_DIR(tools) -AM_INIT_AUTOMAKE(nonesuch, nonesuch) +set -e + +cat > configure.in << END +AC_INIT([$me], [1.0]) +AC_CONFIG_AUX_DIR([tools]) +AM_INIT_AUTOMAKE AC_PROG_CC AM_PROG_CC_C_O -AC_OUTPUT(Makefile foo/Makefile) +AC_CONFIG_FILES([Makefile foo/Makefile]) +AC_OUTPUT END mkdir tools foo foo/bar @@ -33,12 +36,14 @@ cat > Makefile.am << 'END' SUBDIRS = foo END -cat > foo/Makefile.am << 'EOF' +cat > foo/Makefile.am << 'END' AUTOMAKE_OPTIONS = subdir-objects bin_PROGRAMS = mumble mumble_SOURCES = bar/a.c -EOF +END + +$ACLOCAL +$AUTOMAKE --add-missing +test -f tools/compile -$ACLOCAL || Exit 1 -$AUTOMAKE --add-missing || Exit 1 -test -f tools/compile || Exit 1 +: diff --git a/tests/subobj9.test b/tests/subobj9.test index 2b331e024..2045d58e9 100755 --- a/tests/subobj9.test +++ b/tests/subobj9.test @@ -19,13 +19,13 @@ required='libtoolize g++' . ./defs || Exit 1 -cat > configure.in << 'END' -AC_INIT(x, 0, x) -AM_INIT_AUTOMAKE([subdir-objects]) +set -e +cat > configure.in << END +AC_INIT([$me], [1.0]) +AM_INIT_AUTOMAKE([subdir-objects]) AC_PROG_CXX AM_PROG_LIBTOOL - AC_CONFIG_FILES([Makefile]) AC_OUTPUT END @@ -33,7 +33,7 @@ END cat > Makefile.am << 'END' noinst_LTLIBRARIES = libfoo.la libfoo_la_SOURCES = src/foo.cc .//src/bar.cc # the `.//' is meant. - +.PHONY: print print: @echo BEG1: "$(LTCXXCOMPILE)" :1END @echo BEG2: "$(CXXLINK)" :2END @@ -55,7 +55,6 @@ int doit2 (void) } END -set -e libtoolize --force $ACLOCAL @@ -65,17 +64,19 @@ $AUTOMAKE -a # Skip this test on configure errors (e.g., broken C++ compilers). ./configure || Exit 77 -# opportunistically check that --tag=CXX is used when supported -if test -n "`./libtool --help | grep tag=TAG`"; then - $MAKE print >stdout +# Opportunistically check that --tag=CXX is used when supported. +if ./libtool --help | grep tag=TAG; then + $MAKE print >stdout || { cat stdout; Exit 1; } cat stdout grep 'BEG1: .*--tag=CXX.*--mode=compile.* :1END' stdout grep 'BEG2: .*--tag=CXX.*--mode=link.* :2END' stdout fi $MAKE -$MAKE distcheck 2>&1 | tee out +$MAKE distcheck >output 2>&1 || { cat output; Exit 1; } +cat output # GNU Make used to complain that the Makefile contained two rules # for `src/.dirstamp' and `.//src/.dirstamp'. -grep 'overriding commands' out && Exit 1 +grep 'overriding commands' output && Exit 1 + : diff --git a/tests/subobjname.test b/tests/subobjname.test index 79584cf26..a8128bb0e 100755 --- a/tests/subobjname.test +++ b/tests/subobjname.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002, 2010 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 @@ -70,3 +70,5 @@ dobj=`sed -n '/^am_d_OBJECTS = / { p }' Makefile.in` test "$cobj" = "$dobj" + +: -- 2.47.2