tests: refactor some tests on DIST_COMMON
authorStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 22 Dec 2014 15:59:38 +0000 (16:59 +0100)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 22 Dec 2014 16:17:35 +0000 (17:17 +0100)
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>
t/distcom-subdir.sh
t/distcom2.sh
t/distcom3.sh
t/distcom4.sh
t/distcom5.sh
t/hdr-vars-defined-once.sh

index b3651f1cdf8923c5d138da0b7db4382f23ae5661..df40f96cd8e406c264ea02d74ad9af4f706b1fb0 100644 (file)
@@ -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
 # 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
 
 :
index 1f39b6679b7bca269cf6c589c4cbaf6fdb7c1e0d..0cb9307d44c07a206fe5bccdfeeae54f8bc547c8 100644 (file)
@@ -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
 
index d5dc295c59d304820aa159b8b3a746da43b69cf2..6f1ebaf3acc38b28bb121726104816b2dc9d1326 100644 (file)
@@ -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
 
 . 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
index 3febb61e8dd53b2de60f0fc96ee7f8b7788d3654..39b5b717934b819112826e708616809f90cd020b 100644 (file)
@@ -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
 
 :
index 72f51869ff118b346160ca36f95ec19d66cf627a..939702f142d62e3daeaa9e07af55afa482e9f151 100644 (file)
@@ -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
 
 . 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
 
 :
index 91fbcb63bf31c5454880985904ccb0b18cd0edf4..fdf0bb76db057930fac2d797cb1a70f23a89d763 100644 (file)
@@ -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
 
 :