automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {maint} tests: simplify checks for some expected variables values


From: Stefano Lattarini
Subject: [FYI] {maint} tests: simplify checks for some expected variables values in Makefiles
Date: Wed, 19 Jun 2013 17:31:22 +0200

Do so by using our custom 'is' auxiliary script rather than grepping
the output from make.  This is more natural, more robust, and often
shorter to write.

Unfortunately, we can't do that in all cases: sometimes we really need
to match the content of a variable against a regular expressions, and
we can't know nor are interested in its exact value.

This is basically a follow-up on commit v1.11-1830-g96401cb of
2012-02-08 (tests: better way to compare lists in Makefile rules).

* t/subst-no-trailing-empty-line.sh: Adjust.
* t/pluseq10.sh: Likewise.
* t/check5.sh: Likewise, and enhance a little while at it.
* t/check7.sh: Likewise.
* t/exeext.sh: Likewise.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 t/check5.sh                       |  9 ++++-----
 t/check7.sh                       |  9 ++++-----
 t/exeext.sh                       | 35 +++++++++++++++--------------------
 t/pluseq10.sh                     |  8 +++-----
 t/subst-no-trailing-empty-line.sh | 24 +++++++++++-------------
 5 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/t/check5.sh b/t/check5.sh
index 738b3a1..5351ff8 100644
--- a/t/check5.sh
+++ b/t/check5.sh
@@ -32,9 +32,8 @@ check-local:
        test -f one$(EXEEXT)
        test -f two$(EXEEXT)
        touch ok
-.PHONY: print-tests
-print-tests:
-       echo BEG: $(TESTS) :END
+expect-tests:
+       is $(TESTS) == one$(EXEEXT) two$(EXEEXT)
 END
 
 $ACLOCAL
@@ -52,8 +51,8 @@ cp one.c two.c
 ./configure
 $MAKE check
 test -f ok
-run_make -O EXEEXT=.bin print-tests
-$FGREP 'BEG: one.bin two.bin :END' stdout
+run_make expect-tests
+run_make expect-tests EXEEXT=.bin
 # No am__EXEEXT_* variable is needed.
 grep '_EXEEXT_[1-9]' Makefile.in && exit 1
 $FGREP 'TESTS = $(check_PROGRAMS)' Makefile.in
diff --git a/t/check7.sh b/t/check7.sh
index 1dd918b..5d3cd58 100644
--- a/t/check7.sh
+++ b/t/check7.sh
@@ -32,9 +32,8 @@ check_PROGRAMS = a c d
 check_SCRIPTS = b
 EXTRA_DIST = $(check_SCRIPTS)
 
-.PHONY: print-xfail-tests
-print-xfail-tests:
-       @echo BEG: $(XFAIL_TESTS) :END
+expect-xfail-tests:
+       is $(XFAIL_TESTS) == a$(EXEEXT) b c$(EXEEXT) d$(EXEEXT)
 END
 
 cat > b <<'END'
@@ -60,8 +59,8 @@ $AUTOMAKE -a
 
 ./configure
 $MAKE check
-run_make -O EXEEXT=.bin print-xfail-tests
-$FGREP 'BEG: a.bin b c.bin d.bin :END' stdout
+run_make expect-xfail-tests
+run_make expect-xfail-tests EXEEXT=.bin
 
 $MAKE distcheck
 
diff --git a/t/exeext.sh b/t/exeext.sh
index 7290233..414108d 100644
--- a/t/exeext.sh
+++ b/t/exeext.sh
@@ -32,7 +32,6 @@ AC_OUTPUT
 END
 
 cat > Makefile.am << 'END'
-## Use a different dir for each to make grep easy.
 bin_PROGRAMS = maude
 sbin_PROGRAMS = maude.static
 ## We don't define this one for now.  Probably it is an error.
@@ -46,11 +45,17 @@ if WANT_RMT
   libexec_PROGRAMS = rmt
 endif
 
-print:
-       @echo 1BEG: $(bin_PROGRAMS) :END1
-       @echo 2BEG: $(sbin_PROGRAMS) :END2
-       @echo 3BEG: $(check_PROGRAMS) :END3
-       @echo 4BEG: $(libexec_PROGRAMS) :END4
+test-default:
+       is $(bin_PROGRAMS)      ==  maude$(EXEEXT) mt$(EXEEXT)
+       is $(sbin_PROGRAMS)     ==  maude.static$(EXEEXT)
+       is $(check_PROGRAMS)    ==  maude3$(EXEEXT)
+       is $(libexec_PROGRAMS)  ==  rmt$(EXEEXT)
+
+test-revert:
+       is $(bin_PROGRAMS)      ==  maude$(EXEEXT)
+       is $(sbin_PROGRAMS)     ==  maude.static$(EXEEXT)
+       is $(check_PROGRAMS)    ==  maude3$(EXEEXT)
+       is $(libexec_PROGRAMS)  ==
 END
 
 $ACLOCAL
@@ -68,21 +73,11 @@ test $(grep -c '^bin_PROGRAMS =' Makefile.in) -eq 1
 grep 'maude3__EXEEXT__OBJECTS' Makefile.in && exit 1
 
 ./configure
-
-run_make -O EXEEXT=.foo print
-
-grep '1BEG: maude.foo mt.foo :END1' stdout
-grep '2BEG: maude.static.foo :END2' stdout
-grep '3BEG: maude3.foo :END3' stdout
-grep '4BEG: rmt.foo :END4' stdout
+run_make test-default
+run_make test-default EXEEXT=.foo
 
 ./configure revert=yes
-
-run_make -O EXEEXT=.foo print
-
-grep '1BEG: maude.foo :END1' stdout
-grep '2BEG: maude.static.foo :END2' stdout
-grep '3BEG: maude3.foo :END3' stdout
-grep '4BEG: :END4' stdout
+run_make test-revert
+run_make test-revert EXEEXT=.foo
 
 :
diff --git a/t/pluseq10.sh b/t/pluseq10.sh
index c80d23a..deed6e3 100644
--- a/t/pluseq10.sh
+++ b/t/pluseq10.sh
@@ -38,9 +38,8 @@ foo += b0.h \
   b1.h
 endif
 
-.PHONY: print
-print:
-       @echo BEG: $(foo) :END
+test:
+       is $(foo) == 0.h a0.h a1.h a2.h a3.h
 END
 
 $ACLOCAL
@@ -48,7 +47,6 @@ $AUTOCONF
 $AUTOMAKE
 
 ./configure
-run_make -O print
-$FGREP 'BEG: 0.h a0.h a1.h a2.h a3.h :END' stdout
+$MAKE test
 
 :
diff --git a/t/subst-no-trailing-empty-line.sh 
b/t/subst-no-trailing-empty-line.sh
index 5097f5f..b057d95 100644
--- a/t/subst-no-trailing-empty-line.sh
+++ b/t/subst-no-trailing-empty-line.sh
@@ -58,10 +58,15 @@ check_PROGRAMS = zardoz \$(noinst_PROGRAMS)
 ## PROGRAMS primary, otherwise automake will complain.
 EXTRA_PROGRAMS =
 
-print-programs:
-       @echo BEG1: \$(noinst_PROGRAMS) :END1
-       @echo BEG2: \$(bin_PROGRAMS) :END2
-       @echo BEG3: \$(check_PROGRAMS) :END3
+test-real-empty:
+       is \$(noinst_PROGRAMS) == x
+       is \$(bin_PROGRAMS)    ==
+       is \$(check_PROGRAMS)  == zardoz x
+
+test-fake-empty:
+       is \$(noinst_PROGRAMS) == x X
+       is \$(bin_PROGRAMS)    == X
+       is \$(check_PROGRAMS)  == zardoz x X
 END
 
 $ACLOCAL
@@ -82,14 +87,7 @@ test $($EGREP -c "^[ address@hidden@ @address@hidden 
$tab]*$bs?$" Makefile.in) -eq 3
 cat t-programs
 grep '^ *$' t-programs && exit 1
 
-run_make -O print-programs
-grep '^BEG1: x :END1$' stdout
-grep '^BEG2: :END2$' stdout
-grep '^BEG3: zardoz x :END3$' stdout
-
-run_make -O am__empty=X print-programs
-grep '^BEG1: x X :END1$' stdout
-grep '^BEG2: X :END2$' stdout
-grep '^BEG3: zardoz x X :END3$' stdout
+run_make test-real-empty
+run_make test-fake-empty am__empty=X
 
 :
-- 
1.8.3.1.437.g0dbd812




reply via email to

[Prev in Thread] Current Thread [Next in Thread]