[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] {master} tests: better way to compare lists in Makefile rule
From: |
Stefano Lattarini |
Subject: |
Re: [PATCH] {master} tests: better way to compare lists in Makefile rules |
Date: |
Wed, 08 Feb 2012 10:09:44 +0100 |
On 02/06/2012 07:29 PM, Stefano Lattarini wrote:
> 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 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:
>
> ## Don't work because $(VAR) expands to multiple words
> verify:
> test $(VAR) = "valA val1 valC"
>
> nor like:
>
> ## Don'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 details 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:
>
> # Works, but is ugly.
> verify:
> test "`echo $(VAR)`" = "valA val1 valC"
>
> or:
>
> # 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
>
I've pushed this patch now.
Regards,
Stefano