diff options
author | Paul Smith <psmith@gnu.org> | 2005-06-09 19:19:20 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2005-06-09 19:19:20 +0000 |
commit | dd30b0552ffc4276e1ada07100b7eb4e231805fa (patch) | |
tree | 70560f2abb0526fa4dee4e3309f24fb6b202f425 /tests/scripts/functions/foreach | |
parent | af88a3550a6202361aa9eab7e59d83b0bf2c1610 (diff) | |
download | gunmake-dd30b0552ffc4276e1ada07100b7eb4e231805fa.tar.gz |
Fix Savannah bug #11913: ensure that scopes such as foreach, etc. take
precedence over the global scope when they're used in a global context
(such as an eval).
Diffstat (limited to 'tests/scripts/functions/foreach')
-rw-r--r-- | tests/scripts/functions/foreach | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/tests/scripts/functions/foreach b/tests/scripts/functions/foreach index b80751b..1fde12e 100644 --- a/tests/scripts/functions/foreach +++ b/tests/scripts/functions/foreach @@ -1,6 +1,6 @@ # -*-perl-*- -# Updated 6.16.93 variable "MAKE" is default was environment override +# Updated 16 June 1993 variable "MAKE" is default was environment override # For make 3.63 and above $description = "The following test creates a makefile to verify @@ -14,40 +14,47 @@ form of the command is $(foreach var,$list,$text). Several types of foreach loops are tested\n"; -open(MAKEFILE,"> $makefile"); - -# The Contents of the MAKEFILE ... +# TEST 0 # On WIN32 systems, the user's path is found in %Path% ($Path) # $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH"); -print MAKEFILE <<EOF; -foo = bletch null \@ garf +run_make_test(" null := space = ' ' -auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ < -av = \$(foreach var, \$(auto_var), \$(origin \$(var)) ) +auto_var = udef space CC null $pathvar".' MAKE foo CFLAGS WHITE @ < +foo = bletch null @ garf +av = $(foreach var, $(auto_var), $(origin $(var)) ) override WHITE := BLACK -for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) ) -fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) ) +for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) ) +fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) ) all: auto for2 -auto : -\t\@echo \$(av) -for2: -\t\@echo \$(fe) -EOF +auto : ; @echo $(av) +for2: ; @echo $(fe)', + '-e WHITE=WHITE CFLAGS=', + "undefined file default file environment default file command line override automatic automatic +foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o"); + + +# TEST 1: Test that foreach variables take precedence over global +# variables in a global scope (like inside an eval). Tests bug #11913 + +run_make_test(' +.PHONY: all target +all: target -close(MAKEFILE); +x := BAD -&run_make_with_options($makefile, - "-e WHITE=WHITE CFLAGS=", - &get_logfile); +define mktarget +target: x := $(x) +target: ; @echo "$(x)" +endef -# Create the answer to what should be produced by this Makefile -$answer = "undefined file default file environment default file command line override automatic automatic -foo.o bletch.o null.o @.o garf.o .o .o undefined.o file.o default.o file.o environment.o default.o file.o command.o line.o override.o automatic.o automatic.o\n"; +x := GLOBAL -&compare_output($answer,&get_logfile(1)); +$(foreach x,FOREACH,$(eval $(value mktarget)))', + '', + 'FOREACH'); 1; |