Changeset 501 in kBuild for vendor/gnumake/current/tests/scripts/functions/foreach
- Timestamp:
- Sep 15, 2006 2:30:32 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/tests/scripts/functions/foreach
r53 r501 1 1 # -*-perl-*- 2 # $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $ 2 3 3 # Updated 6.16.93 variable "MAKE" is default was environment override 4 # For make 3.63 and above 5 6 $description = "The following test creates a makefile to verify 7 test the foreach function."; 4 $description = "Test the foreach function."; 8 5 9 6 $details = "This is a test of the foreach function in gnu make. … … 15 12 16 13 17 open(MAKEFILE,"> $makefile"); 14 # TEST 0 18 15 19 # The Contents of the MAKEFILE ... 16 # Set an environment variable that we can test in the makefile. 17 $extraENV{FOOFOO} = 'foo foo'; 20 18 21 # On WIN32 systems, the user's path is found in %Path% ($Path) 22 # 23 $pathvar = (($port_type eq 'Windows') ? "Path" : "PATH"); 19 run_make_test("space = ' '".' 20 null := 21 auto_var = udef space CC null FOOFOO MAKE foo CFLAGS WHITE @ < 22 foo = bletch null @ garf 23 av = $(foreach var, $(auto_var), $(origin $(var)) ) 24 override WHITE := BLACK 25 for_var = $(addsuffix .c,foo $(null) $(foo) $(space) $(av) ) 26 fe = $(foreach var2, $(for_var),$(subst .c,.o, $(var2) ) ) 27 all: auto for2 28 auto : ; @echo $(av) 29 for2: ; @echo $(fe)', 30 '-e WHITE=WHITE CFLAGS=', 31 "undefined file default file environment default file command line override automatic automatic 32 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"); 24 33 25 print MAKEFILE <<EOF; 26 foo = bletch null \@ garf 27 null := 28 space = ' ' 29 auto_var = udef space CC null $pathvar MAKE foo CFLAGS WHITE \@ < 30 av = \$(foreach var, \$(auto_var), \$(origin \$(var)) ) 31 override WHITE := BLACK 32 for_var = \$(addsuffix .c,foo \$(null) \$(foo) \$(space) \$(av) ) 33 fe = \$(foreach var2, \$(for_var),\$(subst .c,.o, \$(var2) ) ) 34 all: auto for2 35 auto : 36 \t\@echo \$(av) 37 for2: 38 \t\@echo \$(fe) 39 EOF 34 delete $extraENV{FOOFOO}; 40 35 41 close(MAKEFILE); 36 # TEST 1: Test that foreach variables take precedence over global 37 # variables in a global scope (like inside an eval). Tests bug #11913 42 38 43 &run_make_with_options($makefile, 44 "-e WHITE=WHITE CFLAGS=", 45 &get_logfile); 39 run_make_test(' 40 .PHONY: all target 41 all: target 46 42 47 # Create the answer to what should be produced by this Makefile 48 $answer = "undefined file default file environment default file command line override automatic automatic 49 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"; 43 x := BAD 50 44 51 &compare_output($answer,&get_logfile(1)); 45 define mktarget 46 target: x := $(x) 47 target: ; @echo "$(x)" 48 endef 49 50 x := GLOBAL 51 52 $(foreach x,FOREACH,$(eval $(value mktarget)))', 53 '', 54 'FOREACH'); 55 56 57 # TEST 2: Check some error conditions. 58 59 run_make_test(' 60 x = $(foreach ) 61 y = $x 62 63 all: ; @echo $y', 64 '', 65 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.", 66 512); 67 68 run_make_test(' 69 x = $(foreach ) 70 y := $x 71 72 all: ; @echo $y', 73 '', 74 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.", 75 512); 52 76 53 77 1;
Note:
See TracChangeset
for help on using the changeset viewer.