From d3369343ca79dd1fd112c35eaa20f65bf43cdc02 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 18 Jun 2010 12:56:47 +0200 Subject: [PATCH] New tests on obsoleted usages of automake/autoconf macros. * tests/backcompat.test: New test script. * tests/backcompat2.test: Likewise. * tests/backcompat3.test: Likewise. * tests/backcompat4.test: Likewise. * tests/backcompat5.test: Likewise. * tests/backcompat6.test: Likewise. * tests/init.test: Extended and improved, esp. by trying more combinations of calls to AC_INIT and AM_INIT_AUTOMAKE with few arguments. * tests/Makefile.am (TESTS): Updated. --- ChangeLog | 13 +++++ tests/Makefile.am | 6 ++ tests/Makefile.in | 7 +++ tests/backcompat.test | 66 +++++++++++++++++++++ tests/backcompat2.test | 67 ++++++++++++++++++++++ tests/backcompat3.test | 153 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/backcompat4.test | 64 +++++++++++++++++++++ tests/backcompat5.test | 119 ++++++++++++++++++++++++++++++++++++++ tests/backcompat6.test | 105 +++++++++++++++++++++++++++++++++ tests/init.test | 29 ++++++---- 10 files changed, 618 insertions(+), 11 deletions(-) create mode 100755 tests/backcompat.test create mode 100755 tests/backcompat2.test create mode 100755 tests/backcompat3.test create mode 100755 tests/backcompat4.test create mode 100755 tests/backcompat5.test create mode 100755 tests/backcompat6.test diff --git a/ChangeLog b/ChangeLog index e3559dc..6bbb49f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2010-11-06 Stefano Lattarini + New tests on obsoleted usages of automake/autoconf macros (such + as AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT). + * tests/backcompat.test: New test script. + * tests/backcompat2.test: Likewise. + * tests/backcompat3.test: Likewise. + * tests/backcompat4.test: Likewise. + * tests/backcompat5.test: Likewise. + * tests/backcompat6.test: Likewise. + * tests/init.test: Extended and improved, esp. by trying more + combinations of calls to AC_INIT and AM_INIT_AUTOMAKE with few + arguments. + * tests/Makefile.am (TESTS): Updated. + Fix bug in rules for creating vala vapi/header files. * automake.in (lang_vala_finish_target): Add forgotten "fi" in an if control structure in a generated make rules. Bug introduced diff --git a/tests/Makefile.am b/tests/Makefile.am index 9c81564..e94a0d4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -104,6 +104,12 @@ auxdir.test \ auxdir2.test \ auxdir3.test \ auxdir4.test \ +backcompat.test \ +backcompat2.test \ +backcompat3.test \ +backcompat4.test \ +backcompat5.test \ +backcompat6.test \ backsl.test \ backsl2.test \ backsl3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index b568a09..e249cec 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -280,6 +280,7 @@ gcj6.test \ txinfo5.test parallel_tests = \ +backcompat5-p.test \ check-p.test \ check10-p.test \ check11-p.test \ @@ -371,6 +372,12 @@ auxdir.test \ auxdir2.test \ auxdir3.test \ auxdir4.test \ +backcompat.test \ +backcompat2.test \ +backcompat3.test \ +backcompat4.test \ +backcompat5.test \ +backcompat6.test \ backsl.test \ backsl2.test \ backsl3.test \ diff --git a/tests/backcompat.test b/tests/backcompat.test new file mode 100755 index 0000000..3367db2 --- /dev/null +++ b/tests/backcompat.test @@ -0,0 +1,66 @@ +#! /bin/sh +# Copyright (C) 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test usage of AM_INIT_AUTOMAKE with two ot three arguments, for +# backward-compatibility. + +. ./defs || Exit 1 + +set -e + +cat > Makefile.am <<'END' +.PHONY: test display + +## Might be useful for debugging. +display: + ## The following should be substituted by AM_INIT_AUTOMAKE. + @echo PACKAGE = $(PACKAGE) + @echo VERSION = $(VERSION) + ## The following should not be substituted, as we used the + ## old form of AC_INIT. + @echo PACKAGE_NAME = $(PACKAGE_NAME) + @echo PACKAGE_VERSION = $(PACKAGE_VERSION) + @echo PACKAGE_TARNAME = $(PACKAGE_TARNAME) + @echo PACKAGE_STRING = $(PACKAGE_STRING) + +test: display + test x'$(PACKAGE)' = x'FooBar' + test x'$(VERSION)' = x'0.7.1' + test x'$(PACKAGE_NAME)' = x + test x'$(PACKAGE_VERSION)' = x + test x'$(PACKAGE_TARNAME)' = x + test x'$(PACKAGE_STRING)' = x +END + +for ac_init in 'AC_INIT' 'AC_INIT([Makefile.am])'; do + for am_extra_args in '' ', []' ', [:]' ', [false]'; do + rm -rf autom4te*.cache config* Makefile.in Makefile + cat > configure.in <. + +# Backward-compatibility test: check that AM_INIT_AUTOMAKE with two or +# three arguments does AC_DEFINE the symbols PACKAGE and VERSION iff the +# third argument is empty or non-existent. + +. ./defs || Exit 1 + +set -e + +# A trick to make the test run muuuch faster, by avoiding repeated +# runs of aclocal (one order of magnitude improvement in speed!). +echo 'AC_INIT(x,0) AM_INIT_AUTOMAKE' > configure.in +$ACLOCAL +rm -rf configure.in autom4te.* + +cat > config.h.in <<'END' +#undef PACKAGE +#undef VERSION +END + +for am_arg3 in ':' 'false' '#' ' '; do + cat > configure.in < configure.in <. + +# Backward-compatibility test: check what happens when AC_INIT and +# AM_INIT_AUTOMAKE are both given two or more arguments. + +. ./defs || Exit 1 + +set -e + +empty='' + +cat > Makefile.am <<'END' +## Leading `:;' here required to work around bugs of (at least) bash 3.2 +got: Makefile + @:; { \ + echo 'PACKAGE = $(PACKAGE)'; \ + echo 'VERSION = $(VERSION)'; \ + echo 'PACKAGE_NAME = $(PACKAGE_NAME)'; \ + echo 'PACKAGE_VERSION = $(PACKAGE_VERSION)'; \ + echo 'PACKAGE_STRING = $(PACKAGE_STRING)'; \ + echo 'PACKAGE_TARNAME = $(PACKAGE_TARNAME)'; \ + echo 'PACKAGE_BUGREPORT = $(PACKAGE_BUGREPORT)'; \ + echo 'PACKAGE_URL = $(PACKAGE_URL)'; \ + } >$@ +END + + +### Run 1 ### + +cat > configure.in <exp < configure.in <<'END' +dnl# `AC_INIT' in Autoconf <= 2.63 doesn't have an URL argument. +dnl# Luckily, `AC_AUTOCONF_VERSION' and `m4_version_prereq' are +dnl# both present in autoconf 2.62, which we require; so that we +dnl# can at least use the following workaround. +m4_version_prereq([2.64], + [AC_INIT([ac_name], [ac_version], [ac_bugreport], [ac_tarname], + [ac_url])], + [AC_INIT([ac_name], [ac_version], [ac_bugreport], [ac_tarname]) + AC_SUBST([PACKAGE_URL], [ac_url])]) +AM_INIT_AUTOMAKE([am_name], [am_version]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +cat configure.in + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure + +cat >exp < configure.in <exp <. + +# Backward-compatibility: AC_OUTPUT with arguments. + +. ./defs || Exit 1 + +set -e + +mkdir sub +: > Makefile.am +: > zardoz +: > foo.in +: > foo1.in +: > foo2.in +: > foo3.in +: > sub/bar.in + +ls -l # might be useful for debugging + +for args in \ + 'foo' \ + 'foo:foo1.in' \ + 'foo:zardoz' \ + 'foo:sub/bar.in' \ + 'foo:foo1.in:foo2.in' \ + 'foo:zardoz:zardoz' \ + 'foo:foo1.in:foo2.in:foo3.in' \ + 'foo:foo1.in:foo2.in:sub/bar.in:foo3.in' \ +; do + cat >configure.in <configure.in <. + +# Backward-compatibility test: try to build and distribute a package +# using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT. +# This script can also serve as mild stress-testing for Automke. +# See also the similar test `backcompat6.test'. + +. ./defs || Exit 1 + +set -e + +# Yuck! +cat > configure.in <<'END' +dnl. Everything here is *deliberately* underquoted! +AC_INIT(src/foo.input) +AM_INIT_AUTOMAKE(foo, 1.0) +AC_CONFIG_FILES(Makefile:mkfile.in) +AC_OUTPUT(hacky/Makefile src/Makefile data/Makefile tests/Makefile) +END + +distdir=foo-1.0 + +cat > mkfile.am <<'END' +SUBDIRS = src data tests hacky +installcheck-local: + grep DataDataData $(DESTDIR)$(prefix)/data/$(PACKAGE)-$(VERSION)/bar +END + +mkdir hacky src tests data + +echo 'This is a dummy package' > README + +cat > src/foo.input <<'END' +#!sh +echo Zardoz +END + +cat > tests/a.test <<'END' +#!/bin/sh +"$srcdir/../src/foo" | grep Zardoz +END +chmod a+x tests/a.test + +cat > data/bar <<'END' +line1 +line2 +line3 +END + +cat >hacky/Makefile.am <<'END' +dist-hook: + find $(top_distdir) -print ## useful for debugging + chmod a+rx $(top_distdir)/tests/*.test +END + +cat > src/Makefile.am <<'END' +dist_bin_SCRIPTS = foo +foo: foo.input + sed '1s,^#!.*$$,#!/bin/sh,' $(srcdir)/foo.input >$@ + chmod a+x $@ +EXTRA_DIST = foo.input +DISTCLEANFILES = foo +END + +cat > data/Makefile.am <<'END' +nodist_data_DATA = bar +datadir = $(prefix)/data/$(PACKAGE)-$(VERSION) +bar: + echo DataDataData >$@ +distclean-local: + rm -f bar +END + +cat > tests/Makefile.am <<'END' +TESTS = a.test +EXTRA_DIST = $(TESTS) +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +./configure +ls -l . hacky src data tests # useful for debugging +test ! -f mkfile +$MAKE +$MAKE distdir +test ! -f $distdir/Makefile.in +test ! -f $distdir/data/bar +test -f $distdir/src/foo +diff README $distdir/README +diff mkfile.in $distdir/mkfile.in +diff tests/a.test $distdir/tests/a.test +diff src/foo.input $distdir/src/foo.input + +$MAKE check +$MAKE distcheck + +test -f $distdir.tar.gz + +chmod a-x tests/a.test +# dist-hook should take care of making test files executables +$MAKE distcheck + +: diff --git a/tests/backcompat6.test b/tests/backcompat6.test new file mode 100755 index 0000000..534ecb1 --- /dev/null +++ b/tests/backcompat6.test @@ -0,0 +1,105 @@ +#! /bin/sh +# Copyright (C) 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 +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Backward-compatibility test: try to build and distribute a package +# using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT. +# This script can also serve as mild stress-testing for Automke. +# See also the similar test `backcompat5.test'. + +. ./defs || Exit 1 + +set -e + +# Anyone doing something like this in a real-life package probably +# deserves to be killed. +cat > configure.in <<'END' +dnl. Everything here is *deliberately* underquoted! +AC_INIT(quux.c) +PACKAGE=nonesuch-zardoz +VERSION=nonesuch-0.1 +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AC_SUBST(one,1) +two=2 +AC_SUBST(two, $two) +three=3 +AC_SUBST(three) +AC_PROG_CC +AC_CONFIG_HEADERS(config.h:config.hin) +AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in) +END + +echo @one@ > foo1.in +echo @two@ > foo2.in +echo @three@ > foo3.in + +cat >config.hin <<'END' +#undef PACKAGE +#undef VERSION +END + +cat >> Makefile.am <<'END' +bin_PROGRAMS = foo +foo_SOURCES = quux.c +DISTCLEANFILES = *.tmp +check-local: + rm -f exp got + echo 'PACKAGE = nonesuch-zardoz' > exp.tmp + echo 'VERSION = nonesuch-0.1' >> exp.tmp + echo 'PACKAGE = $(PACKAGE)' > got1.tmp + echo 'VERSION = $(VERSION)' >> got1.tmp + ./foo > got2.tmp + cat exp.tmp + cat got1.tmp + cat got2.tmp + diff exp.tmp got1.tmp + diff exp.tmp got2.tmp +END + +cat > quux.c <<'END' +#include +#include +int main (void) +{ + printf("PACKAGE = %s\nVERSION = %s\n", PACKAGE, VERSION); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE +$AUTOCONF + +./configure + +cat >foo.exp <<'END' +1 +2 +3 +END + +diff foo.exp foo.got + +$MAKE +$MAKE check + +distdir=nonesuch-zardoz-nonesuch-0.1 +$MAKE distdir +test -f $distdir/quux.c +test ! -f $distdir/foo.got + +$MAKE distcheck + +: diff --git a/tests/init.test b/tests/init.test index 38ec681..895bad6 100755 --- a/tests/init.test +++ b/tests/init.test @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008, 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 @@ -14,20 +14,27 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# Make sure we give a sensible error message when neither AC_INIT nor -# AM_INIT_AUTOMAKE are given arguments. +# Make sure we give a sensible error message when AC_INIT and +# AM_INIT_AUTOMAKE are both given less than two arguments. . ./defs || Exit 1 set -e -cat >configure.in <configure.in <stderr && { cat stderr >&2; Exit 1; } + cat stderr >&2 + $FGREP AC_PACKAGE_VERSION stderr && Exit 1 + grep 'configure\.in:.* AC_INIT .*arguments' stderr + done +done -# The error message should mension AC_INIT, not AC_PACKAGE_VERSION. -($ACLOCAL && $AUTOCONF) 2>stderr && { cat stderr >&2; Exit 1; } -cat stderr >&2 -grep AC_PACKAGE_VERSION stderr && Exit 1 -grep AC_INIT stderr +: -- 2.7.4