Ping on this? Reference: <http://lists.gnu.org/archive/html/automake-patches/2010-11/msg00214.html>
Since I was at it, I've rebased the patch on latest maint, and amended it slightly to prefer (even more) make-time tests over grepping tests. The amended patch and the squashed-in diffs are attached. I will wait the customary 72 hours (until friday evening) before pushing. Regards, Stefano
diff --git a/ChangeLog b/ChangeLog index d12938a..788f4fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,13 +6,11 @@ * tests/colon.test: Made more "semantic", as described above. * tests/colon5.test: Likewise. * tests/colon6.test: Likewise. + * tests/colon7.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. Escape literal - dots in grep regexps. Extend comments. 2010-11-25 Stefano Lattarini <stefano.lattar...@gmail.com> diff --git a/tests/colon7.test b/tests/colon7.test index 1c21fd7..fd60a11 100755 --- a/tests/colon7.test +++ b/tests/colon7.test @@ -34,11 +34,16 @@ AC_OUTPUT(subdir/bar:subdir/foo \ ) END -: > Makefile.am - mkdir subdir -: > subdir/Makefile.am +: > Makefile.am : > subdir/foo +cat > subdir/Makefile.am << 'END' +.PHONY: test +test: + ## DIST_COMMON should contain `foo', not `subdir/foo'. + case '$(DIST_COMMON)' in *subdir/foo*) exit 1;; *) exit 0;; esac + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]foo ' +END $ACLOCAL $AUTOMAKE @@ -46,25 +51,9 @@ $AUTOMAKE # Should nowhere refer to `bar.in'. grep 'bar\.in' Makefile.in subdir/Makefile.in && Exit 1 -# DIST_COMMON should contain `foo', not `subdir/foo'. -# FIXME: Do something like this after planned enhancements 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 +$AUTOCONF +./configure +cd subdir +$MAKE test :
From 6d06dff283cfed7e9f2964f85f4aaf25d4cac271 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Wed, 17 Nov 2010 00:40:42 +0100 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/colon7.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). --- ChangeLog | 14 ++++++++++ tests/colon.test | 15 ++++++++++- tests/colon2.test | 49 +++++++++++++++++++++++++++++++++--- tests/colon3.test | 59 +++++++++++++++++++++++++++++++++--------- tests/colon5.test | 43 ++++++++++++++++++++++++------- tests/colon6.test | 72 ++++++++++++++++++++++++++++++++++++++++++++--------- tests/colon7.test | 27 +++++++++++++------ 7 files changed, 230 insertions(+), 49 deletions(-) diff --git a/ChangeLog b/ChangeLog index e8864f1..788f4fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-12-07 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/colon7.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). + 2010-11-25 Stefano Lattarini <stefano.lattar...@gmail.com> Fix spurious failures in `silent*.test' for $CC != gcc 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 9dae9c8..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 -e '/@SET_MAKE@/d' -e "s...@shell@!$SHELL!g" <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 7c620d6..c29d629 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 become too fragile. $EGREP 'Makefile:.*(demo|version)' demo/Makefile.in && Exit 1 grep 'version\.good:.*version\.gin' demo/Makefile.in -sed -e '/@SET_MAKE@/d' -e "s...@shell@!$SHELL!g" <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..fd60a11 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 @@ -32,19 +34,26 @@ AC_OUTPUT(subdir/bar:subdir/foo \ ) END -: > Makefile.am - mkdir subdir -: > subdir/Makefile.am +: > Makefile.am : > subdir/foo +cat > subdir/Makefile.am << 'END' +.PHONY: test +test: + ## DIST_COMMON should contain `foo', not `subdir/foo'. + case '$(DIST_COMMON)' in *subdir/foo*) exit 1;; *) exit 0;; esac + echo ' ' $(DIST_COMMON) ' ' | grep '[ /]foo ' +END $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 +$AUTOCONF +./configure +cd subdir +$MAKE test : -- 1.7.1