diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2014-12-22 16:59:38 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2014-12-22 17:17:35 +0100 |
commit | 986a82e394ee7d8284e67e4d6bc3585daf485ac3 (patch) | |
tree | 12968066a4a040874912b7c9229a5373b77c67f3 | |
parent | cfc6916ef499014b71e874924f1077e8c0604f89 (diff) | |
download | automake-986a82e394ee7d8284e67e4d6bc3585daf485ac3.tar.gz |
tests: refactor some tests on DIST_COMMON
So that they prefer checking the semantics of the generated Makefiles,
rather than grepping their content. This will be useful in an upcoming
refactoring.
* t/distcom-subdir.sh: Adjust this test.
* t/distcom2.sh: And this.
* t/distcom3.sh: And this.
* t/distcom4.sh: And this.
* t/distcom5.sh: And this.
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
-rw-r--r-- | t/distcom-subdir.sh | 53 | ||||
-rw-r--r-- | t/distcom2.sh | 14 | ||||
-rw-r--r-- | t/distcom3.sh | 24 | ||||
-rw-r--r-- | t/distcom4.sh | 30 | ||||
-rw-r--r-- | t/distcom5.sh | 44 | ||||
-rw-r--r-- | t/hdr-vars-defined-once.sh | 25 |
6 files changed, 79 insertions, 111 deletions
diff --git a/t/distcom-subdir.sh b/t/distcom-subdir.sh index b3651f1cd..df40f96cd 100644 --- a/t/distcom-subdir.sh +++ b/t/distcom-subdir.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2004-2013 Free Software Foundation, Inc. +# Copyright (C) 2004-2014 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 @@ -17,59 +17,60 @@ # Test to make sure that if an auxfile (here depcomp) is required # by a subdir Makefile.am, it is distributed by that Makefile.am. +required=cc . test-init.sh cat >> configure.ac << 'END' AC_CONFIG_FILES([subdir/Makefile]) AC_PROG_CC +AC_PROG_FGREP AC_OUTPUT END cat > Makefile.am << 'END' SUBDIRS = subdir +test-distdir: distdir + test -f $(distdir)/depcomp +.PHONY: test-distdir +check-local: test-distdir END rm -f depcomp mkdir subdir -: > subdir/Makefile.am +cat > subdir/Makefile.am << 'END' +.PHONY: test-distcom +test-distcom: + echo ' ' $(DIST_COMMON) ' ' | $(FGREP) ' $(top_srcdir)/depcomp ' +END $ACLOCAL $AUTOCONF $AUTOMAKE test ! -e depcomp -cat > subdir/Makefile.am << 'END' +cat >> subdir/Makefile.am << 'END' bin_PROGRAMS = foo +.PHONY: test-distcom +test-distcom: + echo ' ' $(DIST_COMMON) ' ' | $(FGREP) ' $(top_srcdir)/depcomp ' +check-local: test-distcom END -: > subdir/foo.c +cat > subdir/foo.c <<'END' +int main (void) +{ + return 0; +} +END $AUTOMAKE -a subdir/Makefile test -f depcomp -# FIXME: the logic of this check and other similar ones in other -# FIXME: 'distcom*.sh' files should be factored out in a common -# FIXME: subroutine in 'am-test-lib.sh'... -sed -n -e " - /^DIST_COMMON =.*\\\\$/ { - :loop - p - n - t clear - :clear - s/\\\\$/\\\\/ - t loop - s/$/ / - s/[$tab ][$tab ]*/ /g - p - n - }" subdir/Makefile.in > dc.txt -cat dc.txt -$FGREP ' $(top_srcdir)/depcomp ' dc.txt - ./configure -$MAKE distdir -test -f $distdir/depcomp +(cd subdir && $MAKE test-distcom) +$MAKE test-distdir + +$MAKE distcheck : diff --git a/t/distcom2.sh b/t/distcom2.sh index 1f39b6679..0cb9307d4 100644 --- a/t/distcom2.sh +++ b/t/distcom2.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 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 @@ -51,22 +51,18 @@ for opt in '' --no-force; do test -f depcomp for dir in . subdir; do - # FIXME: the logic of this check and other similar ones in other - # FIXME: 'distcom*.sh' files should be factored out in a common - # FIXME: subroutine in 'am-test-lib.sh'... sed -n -e " - /^DIST_COMMON =.*\\\\$/ { + /^\\(am__\\)\\?DIST_COMMON =.*/ { + b body :loop - p n - t clear - :clear + :body + p s/\\\\$/\\\\/ t loop s/$/ / s/[$tab ][$tab ]*/ /g p - n }" $dir/Makefile.in > $dir/dc.txt done diff --git a/t/distcom3.sh b/t/distcom3.sh index d5dc295c5..6f1ebaf3a 100644 --- a/t/distcom3.sh +++ b/t/distcom3.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2001-2013 Free Software Foundation, Inc. +# Copyright (C) 2001-2014 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,9 +19,13 @@ . test-init.sh +echo AC_OUTPUT >> configure.ac + cat > Makefile.am << 'END' README: echo 'I bet you are reading me.' > README +test-distcommon: + echo ' ' $(DIST_COMMON) ' ' | grep ' README ' END # Files required by '--gnu'. @@ -36,20 +40,14 @@ $AUTOMAKE --add-missing --gnu >output 2>&1 || { cat output; exit 1; } cat output grep README output && exit 1 -sed -n -e '/^DIST_COMMON =.*\\$/ { - :loop - p - n - t clear - :clear - s/\\$/\\/ - t loop - p - n - }' -e '/^DIST_COMMON =/ p' Makefile.in | grep README - +$AUTOCONF +./configure +$MAKE test-distcommon +$MAKE distdir +test -f $distdir/README # Should warn about missing README. +rm -f README : > Makefile.am AUTOMAKE_fails --add-missing --gnu grep 'required file.*README.*not found' stderr diff --git a/t/distcom4.sh b/t/distcom4.sh index 3febb61e8..39b5b7179 100644 --- a/t/distcom4.sh +++ b/t/distcom4.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 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 @@ -43,8 +43,13 @@ mkdir tests : > README : > tests/wrapper.in cat > Makefile.am << 'END' -.PHONY: test -test: distdir +.PHONY: test1 test 2 +test1: + for x in $(DIST_COMMON); do echo $$x; done \ + | grep 'tests/' > lst + cat lst # For debugging. + test `wc -l <lst` -eq 1 +test2: distdir test -f $(distdir)/tests/wrapper.in END @@ -52,23 +57,6 @@ $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing ./configure -$MAKE test - -sed -n -e '/^DIST_COMMON =.*\\$/ { - :loop - p - n - t clear - :clear - s/\\$/\\/ - t loop - p - n - }' -e '/^DIST_COMMON =/ p' Makefile.in > dc.txt - -cat dc.txt # For debugging. - -test 1 -eq $(grep -c tests dc.txt) -grep configure dc.txt +$MAKE test1 test2 : diff --git a/t/distcom5.sh b/t/distcom5.sh index 72f51869f..939702f14 100644 --- a/t/distcom5.sh +++ b/t/distcom5.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2003-2013 Free Software Foundation, Inc. +# Copyright (C) 2003-2014 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,21 +21,6 @@ . test-init.sh -extract_distcommon () -{ - sed -n -e '/^DIST_COMMON =.*\\$/ { - :loop - p - n - t clear - :clear - s/\\$/\\/ - t loop - p - n - }' -e '/^DIST_COMMON =/ p' ${1+"$@"} -} - cat >> configure.ac << 'END' AC_CONFIG_FILES([tests/autoconf:tests/wrapper.in], [chmod +x tests/autoconf]) @@ -57,28 +42,31 @@ END mkdir tests : > tests/wrapper.in -: > tests/Makefile.am + cat > Makefile.am << 'END' SUBDIRS = tests .PHONY: test test: distdir test -f $(distdir)/tests/wrapper.in +check-local: test + for x in $(DIST_COMMON); do echo $$x; done \ + | grep tests && exit 1; : +END + +cat > tests/Makefile.am <<'END' +check-local: + for x in $(DIST_COMMON); do echo $$x; done \ + | grep wrapper.in > lst + cat lst # For debugging. + test `wc -l <lst` -eq 1 END $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing ./configure -$MAKE test - -extract_distcommon Makefile.in > top.txt -extract_distcommon tests/Makefile.in > inner.txt - -# Might be useful for debugging. -cat top.txt -cat inner.txt - -test 0 -eq $(grep -c tests top.txt) -test 1 -eq $(grep -c wrapper inner.txt) +$MAKE check +# Sanity check. +test -f tests/lst : diff --git a/t/hdr-vars-defined-once.sh b/t/hdr-vars-defined-once.sh index 91fbcb63b..fdf0bb76d 100644 --- a/t/hdr-vars-defined-once.sh +++ b/t/hdr-vars-defined-once.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# Copyright (C) 1999-2014 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 @@ -25,25 +25,22 @@ END cat > Makefile.am << 'END' include Will_Be_Included_In_Makefile +test-distcommon: + echo ' ' $(DIST_COMMON) ' ' \ + | grep '[ /]Will_Be_Included_In_Makefile ' END -: > Will_Be_Included_In_Makefile +id=0c35bbde7c95b569a +echo "# $id" > Will_Be_Included_In_Makefile $ACLOCAL $AUTOMAKE test $(grep -c '^srcdir' Makefile.in) -eq 1 -# Also make sure include file is distributed. -sed -n -e '/^DIST_COMMON =.*\\$/ { - :loop - p - n - t clear - :clear - s/\\$/\\/ - t loop - p - n - }' -e '/^DIST_COMMON =/ p' Makefile.in | grep Will_Be_Included_In_Makefile +$AUTOCONF +./configure +$MAKE test-distcommon +$MAKE distdir +grep "$id" $distdir/Will_Be_Included_In_Makefile : |