summaryrefslogtreecommitdiff
path: root/tests/cond19.test
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-02-06 15:48:30 +0100
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-02-08 10:04:19 +0100
commit96401cb96cb4494023c59850d9f6a2912df22c24 (patch)
treeacbe647e615eced80b901a59d2b12d36c4eb2d3c /tests/cond19.test
parent5066c1b5019b7de419a7b4703c26cb79ee9c713d (diff)
downloadautomake-96401cb96cb4494023c59850d9f6a2912df22c24.tar.gz
tests: better way to compare lists in Makefile rules
With this commit, we introduce a new helper shell script for use in the testsuite, which is meant to allow the test cases to easily check whether two whitespace-separated lists are equal; this ability is particularly useful to check for equality of the contents of make variables that are expected to contain multiple whitespace-separated words, and are defined through line continuations (or are rewritten by automake in this way), or that contain expansion of potentially empty variables. Before this change, a test checking that an usage like this one: VAR = valA if COND1 VAR += val1 # com1 endif COND1 VAR += valC worked as expected, couldn't use rules like: ## Doesn't work because $(VAR) expands to multiple words verify: test $(VAR) = "valA val1 valC" nor like: ## Doesn't work because the final expansion of $(VAR) contains ## repeated contiguous whitespace characters (it actually ## equals "valA val1 valC", not "valA val1 valC"), and this ## is an internal detail which might change and which we don't ## want to explicitly rely on. verify: test "$(VAR)" = "valA val1 valC" Instead, we had to rely on cumbersome workaround such as: ## This works, but is ugly. verify: test "`echo $(VAR)`" = "valA val1 valC" or: ## This works, but is even uglier. verify: echo BEG: $(VAR) :END | grep "BEG: valA val1 valC :END" Now, with the help of the new 'is' script, we can perform such a check in a clearer and more straightforward way, as in: ## Works, and reads clearly. verify: is $(VAR) == valA val1 valC * tests/is: New helper shell script, telling whether two whitespace separated lists are equal. * Makefile.am (EXTRA_DIST): Add it. * tests/colneq2.test: Use the new helper script, and accordingly get rid of older, more cumbersome idioms. * tests/cond11.test: Likewise. * tests/cond16.test: Likewise. * tests/cond18.test: Likewise. * tests/cond22.test: Likewise. * tests/cond31.test: Likewise. * tests/cond38.test: Likewise. * tests/test-logs-repeated.test: Likewise. * tests/objext-pr10128.test: Likewise. * tests/programs-primary-rewritten.test: Likewise. * tests/substre2.test: Likewise. Also ... (configure.in, Makefile.am): Add a couple of hack to avoid having to require (and run) a C compiler; accordingly ... ($required): ... remove this. * tests/exeext4.test: Likewise. * tests/substref.test: Likewise. Also ... (hello.c): Use ": >" rather than "cat <<EOF" to generate it, since it's meant to be empty anyway. * tests/cond4.test: Use the new helper script, and accordingly get rid of older, more cumbersome idioms. Avoid some unnecessary uses of "make -e" since we are at it. * tests/cond19.test: Likewise. * tests/cond32.test: Likewise. * tests/cond6.test: Use the new helper script, and accordingly move some checks in the Makefile.am. Avoid unnecessary execution of automake remake rules by manually "touching" aclocal.m4
Diffstat (limited to 'tests/cond19.test')
-rwxr-xr-xtests/cond19.test14
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/cond19.test b/tests/cond19.test
index d1ba08a31..17ead91de 100755
--- a/tests/cond19.test
+++ b/tests/cond19.test
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2001, 2002, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2011, 2012 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
@@ -48,11 +48,9 @@ endif
helldl_SOURCES = $(var3:.c=1.c) $(var4:.c=2.c)
-got = `echo $(helldl_SOURCES) $(helldl_OBJECTS)`
-
.PHONY: test
test:
- test x"$(exp)" = x"$(got)"
+ is $(exp) == $(helldl_SOURCES) $(helldl_OBJECTS)
END
$ACLOCAL
@@ -60,12 +58,12 @@ $AUTOCONF
$AUTOMAKE -a -i
CONDITION1=true CONDITION2=true ./configure
-exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o' $MAKE -e test
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
CONDITION1=true CONDITION2=false ./configure
-exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o' $MAKE -e test
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
CONDITION1=false CONDITION2=true ./configure
-exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o' $MAKE -e test
+$MAKE test exp='dlmaina1.c dlmainb2.c dlmaina1.o dlmainb2.o'
CONDITION1=false CONDITION2=false ./configure
-exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o' $MAKE -e test
+$MAKE test exp='dlmainb1.c dlmaina2.c dlmainb1.o dlmaina2.o'
: