+2010-12-07 Stefano Lattarini <stefano.lattarini@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.lattarini@gmail.com>
Fix spurious failures in `silent*.test' for $CC != gcc
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
:
# 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
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
:
# Make sure ":" works with files automake generates.
# This test is for multiple ":"s.
+# See also sister test `colon2.test'.
. ./defs || Exit 1
AC_OUTPUT
END
-: > zardoz.am
+cat > zardoz.am <<END
+.PHONY: dummy
+dummy:
+END
+
: > two.in
: > three.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
:
: > 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
:
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
:
# 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.
. ./defs || Exit 1
)
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'.
+$FGREP '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
: