diff options
author | Paul Smith <psmith@gnu.org> | 2011-04-18 01:25:20 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2011-04-18 01:25:20 +0000 |
commit | b34438bee83ee906a23b881f257e684a0993b9b1 (patch) | |
tree | 0e3e16d626762ad9341d6fad782a12080c795c45 /tests | |
parent | 1454a04f81708850353dbdc0807a099c5aaab55b (diff) | |
download | gunmake-b34438bee83ee906a23b881f257e684a0993b9b1.tar.gz |
Add new feature: != shell assignment for portability with BSD make.
Feature submitted by David Wheeler.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ChangeLog | 4 | ||||
-rw-r--r-- | tests/scripts/features/shell_assignment | 65 |
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index b13e2ae..3fdf5ca 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2011-04-17 David A. Wheeler <dwheeler@dwheeler.com> + + * scripts/features/shell_assignment: Regression for "!=" feature + 2010-11-06 Paul Smith <psmith@gnu.org> * scripts/features/targetvars: Fix known-good output for BS/NL changes. diff --git a/tests/scripts/features/shell_assignment b/tests/scripts/features/shell_assignment new file mode 100644 index 0000000..686e4bd --- /dev/null +++ b/tests/scripts/features/shell_assignment @@ -0,0 +1,65 @@ +# -*-perl-*- + +$description = "Test BSD-style shell assignments (VAR != VAL) for variables."; + +$details = ""; + +# TEST 0: Basic shell assignment (!=). + +run_make_test(' +.POSIX: + +demo1!=printf \' 1 2 3\n4\n\n5 \n \n 6\n\n\n\n\' +demo2 != printf \'7 8\n \' +demo3 != printf \'$$(demo2)\' +demo4 != printf \' 2 3 \n\' +demo5 != printf \' 2 3 \n\n\' +all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>" +', + '', "< 1 2 3 4 5 6 > <7 8 > <7 8 > < 2 3 > < 2 3 >\n"); + +# TEST 1: Handle '#' the same way as BSD make + +run_make_test(' +foo1!=echo bar#baz +hash != printf \'\043\' +foo2!= echo "bar$(hash)baz" + +all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>" +', + '', "<bar> <#> <bar#baz>\n"); + +# TEST 2: shell assignment variables (from !=) should be recursive. +# Note that variables are re-evaluated later, so the shell can output +# a value like $(XYZZY) as part of !=. The $(XYZZY) will be EVALUATED +# when the value containing it is evaluated. On the negative side, this +# means if you don't want this, you need to escape dollar signs as $$. +# On the positive side, it means that shell programs can output macros +# that are then evaluated as they are traditionally evaluated.. and that +# you can use traditional macro evaluation semantics to implement !=. + +run_make_test(' +XYZZY = fiddle-dee-dee +dollar = $$ +VAR3 != printf \'%s\' \'$(dollar)(XYZZY)\' + +all: ; @echo "<$(VAR3)>" +', + '', "<fiddle-dee-dee>\n"); + + +# TEST 3: Overrides invoke shell anyway; they just don't store the result +# in a way that is visible. + +run_make_test(' + +override != echo abc > ,abc ; cat ,abc + +all: ; @echo "<$(override)>" ; cat ,abc +', + 'override=xyz', "<xyz>\nabc\n"); + +unlink(',abc'); + + +1; |