Tested on Debian with: GNU make 3.81 + Bash 4.1.5 + GNU tools, Heirloom make + Heirloom shell + Heirloom tools, GNU make 3.80 + Dash 0.5.5.1 + GNU tools, FreeBSD make + ksh (Version JM 93t+ 2009-05-01) + GNU tools.
OK for maint? Regards, Stefano -*-*- Prefer running configure and make over grepping the generated files; this is both more correct and less fragile. * tests/colon.test: Made more "semantic", as described above. * tests/colon5.test: Likewise. * tests/colon6.test: Likewise. * tests/colon2.test: Likewise, and improve syncing with sister test `colon3.test'. * tests/colon3.test: Likewise, but with the sister test being `colon2.test' here. * tests/colon7.test: Make sure to consider all the contents of `$(DIST_COMMON)' when grepping for bad contents. Prefer fgrep over grep to minimize the possibility of false positives. Extend comments. --- ChangeLog | 15 +++++++++++ tests/colon.test | 15 ++++++++++- tests/colon2.test | 49 +++++++++++++++++++++++++++++++++--- tests/colon3.test | 59 +++++++++++++++++++++++++++++++++--------- tests/colon5.test | 43 ++++++++++++++++++++++++------- tests/colon6.test | 72 ++++++++++++++++++++++++++++++++++++++++++++--------- tests/colon7.test | 32 +++++++++++++++++++---- 7 files changed, 239 insertions(+), 46 deletions(-)
From 26311b5e0f52359dd7df706dfd238beefc25d73f Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Mon, 13 Sep 2010 14:39:43 +0200 Subject: [PATCH] Make tests `colon*.test' more "semantic". Prefer running configure and make over grepping the generated files; this is both more correct and less fragile. * tests/colon.test: Made more "semantic", as described above. * tests/colon5.test: Likewise. * tests/colon6.test: Likewise. * tests/colon2.test: Likewise, and improve syncing with sister test `colon3.test'. * tests/colon3.test: Likewise, but with the sister test being `colon2.test' here. * tests/colon7.test: Make sure to consider all the contents of `$(DIST_COMMON)' when grepping for bad contents. Prefer fgrep over grep to minimize the possibility of false positives. Extend comments. --- ChangeLog | 15 +++++++++++ tests/colon.test | 15 ++++++++++- tests/colon2.test | 49 +++++++++++++++++++++++++++++++++--- tests/colon3.test | 59 +++++++++++++++++++++++++++++++++--------- tests/colon5.test | 43 ++++++++++++++++++++++++------- tests/colon6.test | 72 ++++++++++++++++++++++++++++++++++++++++++++--------- tests/colon7.test | 32 +++++++++++++++++++---- 7 files changed, 239 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48c6e79..bbfe894 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2010-09-12 Stefano Lattarini <stefano.lattar...@gmail.com> + Make tests `colon*.test' more "semantic". + Prefer running configure and make over grepping the generated + files; this is both more correct and less fragile. + * tests/colon.test: Made more "semantic", as described above. + * tests/colon5.test: Likewise. + * tests/colon6.test: Likewise. + * tests/colon2.test: Likewise, and improve syncing with sister + test `colon3.test'. + * tests/colon3.test: Likewise, but with the sister test being + `colon2.test' here. + * tests/colon7.test: Make sure to consider all the contents of + `$(DIST_COMMON)' when grepping for bad contents. Prefer fgrep + over grep to minimize the possibility of false positives. + Extend comments. + Fix regression in test `colon4.test'. * tests/colon4.test: Fix botched editing to `configure.in' that made the test useless. Since we are at it, improve diff --git a/tests/colon.test b/tests/colon.test index 22b5ed3..f1eec9a 100755 --- a/tests/colon.test +++ b/tests/colon.test @@ -27,10 +27,23 @@ AC_CONFIG_FILES([foo.h:foo.hin]) AC_OUTPUT END -: > Makefile.am : > foo.hin +cat > Makefile.am <<'END' +.PHONY: test +test: distdir + ls -l . $(distdir) + test -f foo.h + test -f $(distdir)/foo.hin +END + $ACLOCAL $AUTOMAKE +$AUTOCONF + +./configure + +$MAKE test +$MAKE distcheck : diff --git a/tests/colon2.test b/tests/colon2.test index a52dfa8..503f6db 100755 --- a/tests/colon2.test +++ b/tests/colon2.test @@ -16,6 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Make sure ":" works with files automake generates. +# See also sister test `colon3.test'. . ./defs || Exit 1 @@ -28,14 +29,54 @@ AC_CONFIG_FILES([Makefile:zardoz.in]) AC_OUTPUT END -echo 'dummy:' > zardoz.am +cat > zardoz.am <<END +.PHONY: dummy +dummy: +END $ACLOCAL $AUTOMAKE -# We actually check several things here. +# Automake should have created zardoz.in. test -f zardoz.in -grep '^zardoz:' zardoz.in && Exit 1 -grep '^dummy:' zardoz.in + +# The generated file should refer to zardoz.in and zardoz.am, but +# never just "zardoz". +$FGREP 'zardoz.am' zardoz.in +$FGREP 'zardoz.in' zardoz.in +sed -e 's|zardoz\.am|zrdz.am|g' \ + -e 's|zardoz\.in|zrdz.in|g' \ + <zardoz.in | $FGREP 'zardoz' && Exit 1 + +# The configure-generated Makefile should depend on zardoz.in, two.in and +# three.in. The automake-generated zardoz.in should depend on zardoz.am. +# Let's do this check the right way by running configure and make. + +str='%% ZaR DoZ %%' + +$AUTOCONF +./configure +test -f Makefile # sanity check + +$MAKE dummy +# Again, make sure that the generated Makefile do not unduly +# refer to `zardoz' . +$MAKE -n zardoz && Exit 1 + +$sleep +cat >> zardoz.am <<END +check-local: testam testin testmk +.PHONY: testam testin testmk +testam: + grep '$str' \$(srcdir)/zardoz.am +testin: + grep '$str' \$(srcdir)/zardoz.in +testmk: + grep '$str' Makefile +END +$MAKE Makefile # for non-GNU make +$MAKE testam testin testmk + +$MAKE distcheck : diff --git a/tests/colon3.test b/tests/colon3.test index 151d015..e261b72 100755 --- a/tests/colon3.test +++ b/tests/colon3.test @@ -17,6 +17,7 @@ # Make sure ":" works with files automake generates. # This test is for multiple ":"s. +# See also sister test `colon2.test'. . ./defs || Exit 1 @@ -29,7 +30,11 @@ AC_CONFIG_FILES([Makefile:zardoz.in:two.in:three.in]) AC_OUTPUT END -: > zardoz.am +cat > zardoz.am <<END +.PHONY: dummy +dummy: +END + : > two.in : > three.in @@ -41,21 +46,49 @@ test -f zardoz.in # The generated file should refer to zardoz.in and zardoz.am, but # never just "zardoz". +$FGREP 'zardoz.am' zardoz.in +$FGREP 'zardoz.in' zardoz.in sed -e 's|zardoz\.am|zrdz.am|g' \ -e 's|zardoz\.in|zrdz.in|g' \ <zardoz.in | $FGREP 'zardoz' && Exit 1 -# FIXME: Do something like this after planned enahncements to tests/defs. -# FIXME: Or even do proper functional testing. -## Also, Makefile should depend on two.in and three.in. -# extract_makefile_deps Makefile zardoz.in > deps -#$FGREP ' $(srcdir)/two.in ' deps -#$FGREP ' $(srcdir)/three.in ' deps -# -# FIXME: for the moment, we content ourselves with these inferior tests. -# Makefile should depend on two.in. -grep '^Makefile:.* \$(srcdir)/two.in' zardoz.in -# Likewise three.in. -grep '^Makefile:.* \$(srcdir)/three.in' zardoz.in +# The configure-generated Makefile should depend on zardoz.in, two.in and +# three.in. The automake-generated zardoz.in should depend on zardoz.am. +# Let's do this check the right way by running configure and make. + +str='%% ZaR DoZ %%' +str2='// 2_TwO_2 //' +str3='== @thr33@ ==' + +$AUTOCONF +./configure +test -f Makefile # sanity check + +$MAKE dummy +# Again, make sure that the generated Makefile do not unduly +# refer to `zardoz' . +$MAKE -n zardoz && Exit 1 + +$sleep +cat >> zardoz.am <<END +check-local: testam testin testmk test2 test3 +.PHONY: testam testin test2 testmk test3 +testam: + grep '$str' \$(srcdir)/zardoz.am +testin: + grep '$str' \$(srcdir)/zardoz.in +testmk: + grep '$str' Makefile +test2: + grep '$str2' \$(srcdir)/two.in +test3: + grep '$str3' \$(srcdir)/three.in +END +echo "# $str2" >> two.in +echo "# $str3" >> three.in +$MAKE Makefile # for non-GNU make +$MAKE testam testin testmk test2 test3 + +$MAKE distcheck : diff --git a/tests/colon5.test b/tests/colon5.test index c53910e..2db2484 100755 --- a/tests/colon5.test +++ b/tests/colon5.test @@ -31,21 +31,44 @@ END : > Makefile.dep cat > Makefile.am <<'END' -.PHONY: test -test: - case ' $(DIST_COMMON) ' in \ - *' $(srcdir)/Makefile.dep '*|*' Makefile.dep '*) exit 0;; \ - *) exit 1;; \ - esac +.PHONY: test-fs-layout test-grep test-distcommon test-distdir +check-local: test-fs-layout test-grep test-distcommon test-distdir +test-fs-layout: + test x'$(srcdir)' = '.' || test ! -r Makefile.dep +test-grep: +## The use of $(empty) prevents spurious matches. + grep '=GrEp$(empty)Me_am=' $(srcdir)/Makefile.in + grep '=GrEp$(empty)Me_dep=' $(srcdir)/Makefile.dep + grep '=GrEp$(empty)Me_am=' Makefile + grep '=GrEp$(empty)Me_dep=' Makefile +test-distcommon: + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]Makefile.dep ' +test-distdir: distdir + test -f $(distdir)/Makefile.dep END $ACLOCAL +$AUTOCONF $AUTOMAKE -grep 'Makefile:Makefile\.in' Makefile.in -grep '^Makefile:.* \$(srcdir)/Makefile\.dep' Makefile.in +./configure -sed '/@SET_MAKE@/d' <Makefile.in >Makefile.sed -$MAKE -f Makefile.sed SHELL=$SHELL test +grep '=GrEpMe_am=' Makefile && Exit 1 # sanity check +grep '=GrEpMe_dep=' Makefile && Exit 1 # likewise + +$MAKE test-distcommon +$MAKE test-distdir + +$sleep + +echo '# =GrEpMe_am=' >> Makefile.am +echo '# =GrEpMe_dep=' >> Makefile.dep + +$MAKE Makefile # for non-GNU make +$MAKE test-grep +$MAKE test-distcommon +$MAKE test-distdir + +$MAKE distcheck : diff --git a/tests/colon6.test b/tests/colon6.test index 4fb738e..f63a37b 100755 --- a/tests/colon6.test +++ b/tests/colon6.test @@ -24,30 +24,78 @@ set -e cat > configure.in <<END AC_INIT([$me], [1.0]) AM_INIT_AUTOMAKE +## With this, version.good should depend from version.gin, while +## Makefile should not depend from either of them. AC_CONFIG_FILES([demo/Makefile demo/version.good:demo/version.gin]) AC_OUTPUT END mkdir demo - : > demo/version.gin - -cat > demo/Makefile.am <<'END' -.PHONY: test -test: - case ' $(DIST_COMMON) ' in \ - *' $(srcdir)/version.gin '*) exit 0;; \ - *) exit 1;; \ - esac -END +: > demo/Makefile.am $ACLOCAL $AUTOMAKE +# These are older "grepping check", kept mostly for backward-copmatibility. +# They might (unlikely, but possibly) require updating when automake +# internals are changed. Just relax or remove if they becomes too fragile. $EGREP 'Makefile:.*(demo|version)' demo/Makefile.in && Exit 1 grep 'version\.good:.*version\.gin' demo/Makefile.in -sed '/@SET_MAKE@/d' <demo/Makefile.in >Makefile.sed -$MAKE -f Makefile.sed SHELL=$SHELL test +$AUTOCONF + +for vpath in : false; do + + if $vpath; then + srcdir=.. + mkdir build + cd build + else + srcdir=. + fi + + $srcdir/configure + + test -f demo/version.good # sanity check + test ! -s demo/version.good # likewise + + cd demo + + # version.good should depend from version.gin + $sleep + echo "Rebuilt (srcdir=$srcdir)" > ../$srcdir/demo/version.gin + $MAKE version.good + $FGREP "Rebuilt (srcdir=$srcdir)" version.good + + # Makefile should not depend from version.good. + rm -f version.good + $MAKE Makefile + test ! -r version.good + + # version.good should be rebuilt from version.gin + $MAKE version.good + test -f version.good + + # Makefile should not depend from version.gin. + rm -f ../$srcdir/demo/version.gin + $MAKE Makefile + test ! -r ../$srcdir/demo/version.gin # sanity check + + # version.good should depend from version.gin + rm -f version.good + + $MAKE version.good >output 2>&1 && { cat output; Exit 1; } + cat output + # Try to verify that we errored out for the right reason. + $FGREP version.gin output + + cd .. # back in top builddir + cd $srcdir + + # Re-create it for the next pass (if any). + : > demo/version.gin + +done : diff --git a/tests/colon7.test b/tests/colon7.test index 4195188..93714d9 100755 --- a/tests/colon7.test +++ b/tests/colon7.test @@ -15,8 +15,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Another test for a failing ":" in AC_OUTPUT. Report from Maciej -# Stachowiak. +# Another test for a failing ":" in AC_OUTPUT. +# Report from Maciej Stachowiak. +# Note: converting this testcase to functional tests would be quite +# tricky, so we content ourselves with "grepping" tests. . ./defs || Exit 1 @@ -41,10 +43,28 @@ mkdir subdir $ACLOCAL $AUTOMAKE -# shouldn't have any bar.in -grep 'bar.in' subdir/Makefile.in && Exit 1 +# Should nowhere refer to `bar.in'. +grep 'bar.in' Makefile.in subdir/Makefile.in && Exit 1 -# DIST_COMMON should have foo, not subdir/foo -grep 'DIST_COMMON.*subdir/foo' subdir/Makefile.in && Exit 1 +# DIST_COMMON should cntain `foo', not `subdir/foo'. +# FIXME: Do something like this after planned enahncements to tests/defs: +# extract_makefile_variable DIST_COMMON Makefile.in > dc.txt +# grep '[ /]foo ' dc.txt # sanity check +# grep ' subdir/foo ' dc.txt && Exit 1 +# For now, we to have munge Makefile.in by hand... +sed -n -e '/^DIST_COMMON =.*\\$/ { + :loop + p + n + t clear + :clear + s/\\$/\\/ + t loop + p + n + }' -e '/^DIST_COMMON =/ p' subdir/Makefile.in > dc.txt +cat dc.txt # for debugging +grep 'foo' dc.txt # sanity check +grep 'subdir/foo' dc.txt && Exit 1 : -- 1.7.1