Changeset 3140 for trunk/src/kmk/tests/scripts/functions
- Timestamp:
- Mar 14, 2018, 10:28:10 PM (7 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 10 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk
-
Property svn:mergeinfo
set to
/vendor/gnumake/current merged eligible
-
Property svn:mergeinfo
set to
-
trunk/src/kmk/tests/scripts/functions/call
r969 r3140 5 5 results.\n"; 6 6 7 open(MAKEFILE, "> $makefile"); 8 9 # The Contents of the MAKEFILE ... 10 11 print MAKEFILE <<'EOMAKE'; 7 run_make_test(q! 12 8 # Simple, just reverse two things 13 9 # 14 10 reverse = $2 $1 15 11 16 # A complex `map' function, using recursive `call'.12 # A complex 'map' function, using recursive 'call'. 17 13 # 18 14 map = $(foreach a,$2,$(call $1,$a)) … … 39 35 DEP_baz = quux blarp 40 36 rest = $(wordlist 2,$(words ${1}),${1}) 41 tclose = $(if $1,$(firstword $1) 37 tclose = $(if $1,$(firstword $1)\ 42 38 $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1)))) 43 39 … … 49 45 echo '$(call my-if,a,b,c)'; \ 50 46 echo '$(call two,bar,baz)'; \ 51 echo '$(call tclose,foo)' 47 echo '$(call tclose,foo)'; 48 !, 49 "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n"); 52 50 53 54 55 EOMAKE 56 57 # These won't work until/unless PR/1527 is resolved. 58 # echo '$(call my-foreach,a,x y z,$(a)$(a))'; \ 59 # echo '$(call my-if,,$(warning don't print this),ok)' 51 # These won't work because call expands all its arguments first, before 52 # passing them on, then marks them as resolved/simple, so they're not 53 # expanded again by the function. 60 54 # 61 # $answer = "xx yy zz\nok\n"; 62 63 # END of Contents of MAKEFILE 64 65 close(MAKEFILE); 66 67 &run_make_with_options($makefile, "", &get_logfile); 68 $answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n"; 69 &compare_output($answer, &get_logfile(1)); 70 55 # echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \ 56 # echo '$(call my-if,,$$(info don't print this),$$(info do print this))' 57 # 58 # $answer = "xx yy zz\ndo print this\n"; 71 59 72 60 # TEST eclipsing of arguments when invoking sub-calls 73 61 74 $makefile2 = &get_tmpfile; 75 76 open(MAKEFILE,"> $makefile2"); 77 78 print MAKEFILE <<'EOF'; 79 62 run_make_test(q! 80 63 all = $1 $2 $3 $4 $5 $6 $7 $8 $9 81 64 … … 89 72 @echo $(call level2,1,2,3,4,5,6,7,8) 90 73 @echo $(call level3,1,2,3,4,5,6,7,8) 91 EOF 74 !, 75 "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n"); 92 76 93 close(MAKEFILE); 77 # Ensure that variables are defined in global scope even in a $(call ...) 94 78 95 &run_make_with_options($makefile2, "", &get_logfile); 96 $answer = "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n"; 97 &compare_output($answer,&get_logfile(1)); 79 delete $ENV{X123}; 80 81 run_make_test(' 82 tst = $(eval export X123) 83 $(call tst) 84 all: ; @echo "$${X123-not set}" 85 ', 86 '', "\n"); 98 87 99 88 1; 89 90 ### Local Variables: 91 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 92 ### End: -
trunk/src/kmk/tests/scripts/functions/error
r969 r3140 55 55 56 56 &run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512); 57 $answer = "Some stuff\n$makefile:1 6: *** error is definitely. Stop.\n";57 $answer = "Some stuff\n$makefile:17: *** error is definitely. Stop.\n"; 58 58 &compare_output($answer,&get_logfile(1)); 59 59 … … 67 67 1; 68 68 69 70 71 72 73 69 ### Local Variables: 70 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 71 ### End: -
trunk/src/kmk/tests/scripts/functions/filter-out
r969 r3140 1 1 # -*-perl-*- 2 2 3 $description = "Test the filter -out function.";3 $description = "Test the filter and filter-out functions."; 4 4 5 5 $details = "The makefile created in this test has two variables. The … … 12 12 functions is the same single .elc name.\n"; 13 13 14 open(MAKEFILE,"> $makefile"); 14 # Basic test -- filter 15 run_make_test(q! 16 files1 := $(filter %.o, foo.elc bar.o lose.o) 17 files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o) 18 all: ; @echo '$(files1) $(files2)' 19 !, 20 '', "bar.o lose.o foo.i bar.o lose.o\n"); 15 21 16 print MAKEFILE <<'EOF'; 22 # Basic test -- filter-out 23 run_make_test(q! 17 24 files1 := $(filter-out %.o, foo.elc bar.o lose.o) 18 25 files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o) 19 all: ; @echo $(files1) $(files2) 20 EOF 26 all: ; @echo '$(files1) $(files2)' 27 !, 28 '', "foo.elc foo.elc\n"); 21 29 22 close(MAKEFILE); 30 # Escaped patterns 31 run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!, 32 '', "foo%bar\n"); 23 33 24 &run_make_with_options($makefile, "", &get_logfile, 0); 25 $answer = "foo.elc foo.elc\n"; 26 &compare_output($answer,&get_logfile(1)); 34 run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!, 35 '', "foo%%\\%%bar\n"); 36 37 run_make_test(q! 38 X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar) 39 all:;@echo '$(X)'!, 40 '', "foo\\%bar\n"); 27 41 28 42 1; -
trunk/src/kmk/tests/scripts/functions/foreach
r2175 r3140 1 1 # -*-perl-*- 2 # $Id : foreach,v 1.5 2006/03/10 02:20:46 psmith Exp$2 # $Id$ 3 3 4 4 $description = "Test the foreach function."; … … 56 56 'FOREACH'); 57 57 58 # Allow variable names with trailing space 59 run_make_test(q! 60 $(foreach \ 61 a \ 62 , b c d \ 63 , $(info $a)) 64 all:;@: 65 !, 66 "", "b\nc\nd\n"); 58 67 59 # TEST 2: Check some error conditions. 68 # Allow empty variable names. We still expand the body. 69 70 run_make_test(' 71 x = $(foreach ,1 2 3,a) 72 y := $x 73 74 all: ; @echo $y', 75 '', "a a a\n"); 76 77 # Check some error conditions. 60 78 61 79 run_make_test(' … … 65 83 all: ; @echo $y', 66 84 '', 67 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'. Stop.",85 "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'. Stop.", 68 86 512); 69 87 70 88 run_make_test(' 71 x = $(foreach )89 x = $(foreach x,y) 72 90 y := $x 73 91 74 92 all: ; @echo $y', 75 93 '', 76 "#MAKEFILE#:2: *** insufficient number of arguments ( 1) to function `foreach'. Stop.",94 "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'. Stop.", 77 95 512); 78 96 -
trunk/src/kmk/tests/scripts/functions/shell
r2591 r3140 5 5 $details = ''; 6 6 7 # Test standard shell 8 run_make_test('.PHONY: all 9 OUT := $(shell echo hi) 10 all: ; @echo $(OUT) 11 ','','hi'); 7 12 8 13 # Test shells inside rules. 9 14 run_make_test('.PHONY: all 10 15 all: ; @echo $(shell echo hi) 11 ','','hi'); 16 ','','hi'); 17 18 # Verify .SHELLSTATUS 19 run_make_test('.PHONY: all 20 PRE := $(.SHELLSTATUS) 21 $(shell exit 0) 22 OK := $(.SHELLSTATUS) 23 $(shell exit 1) 24 BAD := $(.SHELLSTATUS) 25 all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD) 26 ','','PRE= OK=0 BAD=1'); 12 27 13 28 … … 28 43 .PHONY: all 29 44 all: ; @echo $$HI 30 ','','hi'); 45 ','','hi'); 46 47 # Test shell errors in recipes including offset 48 run_make_test(' 49 all: 50 @echo hi 51 $(shell ./basdfdfsed there) 52 @echo there 53 ', 54 '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n"); 31 55 32 56 1; 57 58 ### Local Variables: 59 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 60 ### End: -
trunk/src/kmk/tests/scripts/functions/sort
r969 r3140 1 $description = "The following test creates a makefile to verify\n" 2 ."the ability of make to sort lists of object. Sort\n" 3 ."will also remove any duplicate entries. This will also\n" 4 ."be tested."; 1 # -*-perl-*- 5 2 6 $details = "The make file is built with a list of object in a random order\n" 7 ."and includes some duplicates. Make should sort all of the elements\n" 8 ."remove all duplicates\n"; 3 $description = "The following test creates a makefile to verify 4 the ability of make to sort lists of object. Sort 5 will also remove any duplicate entries. This will also 6 be tested."; 9 7 10 open(MAKEFILE,"> $makefile"); 8 $details = "The make file is built with a list of object in a random order 9 and includes some duplicates. Make should sort all of the elements 10 remove all duplicates\n"; 11 11 12 # The Contents of the MAKEFILE ... 13 14 print MAKEFILE "foo := moon_light days \n" 15 ."foo1:= jazz\n" 16 ."bar := captured \n" 17 ."bar2 = boy end, has rise A midnight \n" 18 ."bar3:= \$(foo)\n" 19 ."s1 := _by\n" 20 ."s2 := _and_a\n" 21 ."t1 := \$(addsuffix \$(s1), \$(bar) )\n" 22 ."t2 := \$(addsuffix \$(s2), \$(foo1) )\n" 23 ."t3 := \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \n" 24 ."t4 := \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \n" 25 ."t5 := \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \n" 26 ."t6 := \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \n" 27 ."t7 := \$(t6) \$(t6) \$(t6) \n" 28 ."p1 := \$(addprefix \$(foo1), \$(s2) )\n" 29 ."blank:= \n" 30 ."all:\n" 31 ."\t\@echo \$(sort \$(bar2) \$(foo) \$(addsuffix \$(s1), \$(bar) ) \$(t2) \$(bar2) \$(bar3))\n" 32 ."\t\@echo \$(sort \$(blank) \$(foo) \$(bar2) \$(t1) \$(p1) )\n" 33 ."\t\@echo \$(sort \$(foo) \$(bar2) \$(t1) \$(t4) \$(t5) \$(t7) \$(t6) )\n"; 12 run_make_test(' 13 foo := moon_light days 14 foo1:= jazz 15 bar := captured 16 bar2 = boy end, has rise A midnight 17 bar3:= $(foo) 18 s1 := _by 19 s2 := _and_a 20 t1 := $(addsuffix $(s1), $(bar) ) 21 t2 := $(addsuffix $(s2), $(foo1) ) 22 t3 := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) 23 t4 := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) 24 t5 := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) 25 t6 := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) 26 t7 := $(t6) $(t6) $(t6) 27 p1 := $(addprefix $(foo1), $(s2) ) 28 blank:= 29 all: 30 @echo $(sort $(bar2) $(foo) $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3)) 31 @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) ) 32 @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) ) 33 ', 34 '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise 35 A boy captured_by days end, has jazz_and_a midnight moon_light rise 36 A boy captured_by days end, has jazz_and_a midnight moon_light rise 37 '); 34 38 35 39 36 # END of Contents of MAKEFILE 40 # Test with non-space/tab whitespace. Note that you can't see the 41 # original bug except using valgrind. 37 42 38 close(MAKEFILE); 39 40 &run_make_with_options($makefile,"",&get_logfile); 41 42 # Create the answer to what should be produced by this Makefile 43 $answer = "A boy captured_by days end, has jazz_and_a midnight moon_light rise\n" 44 ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n" 45 ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"; 46 47 &compare_output($answer,&get_logfile(1)); 43 run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff 44 all: ; \@echo \$(words \$(sort \$(FOO)))\n", 45 '', "6\n"); 48 46 49 47 1; 50 48 51 52 53 54 55 49 ### Local Variables: 50 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 51 ### End: -
trunk/src/kmk/tests/scripts/functions/warning
r969 r3140 53 53 54 54 &run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0); 55 $answer = "Some stuff\n$makefile:1 4: warning is definitely\nhi\nthere\n";55 $answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n"; 56 56 &compare_output($answer,&get_logfile(1)); 57 58 # Test linenumber offset 59 60 run_make_test(q! 61 all: one two 62 $(warning in $@ line 3) 63 @true 64 $(warning in $@ line 5) 65 66 one two: 67 $(warning in $@ line 8) 68 @true 69 $(warning in $@ line 10) 70 !, 71 '', "#MAKEFILE#:8: in one line 8 72 #MAKEFILE#:10: in one line 10 73 #MAKEFILE#:8: in two line 8 74 #MAKEFILE#:10: in two line 10 75 #MAKEFILE#:3: in all line 3 76 #MAKEFILE#:5: in all line 5\n"); 57 77 58 78 # This tells the test driver that the perl test script executed properly. 59 79 1; 60 80 61 62 63 64 65 81 ### Local Variables: 82 ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action)) 83 ### End: -
trunk/src/kmk/tests/scripts/functions/wildcard
r2591 r3140 89 89 '', "\n"); 90 90 91 # TEST #5: wildcard used to verify file existence 92 93 touch('xxx.yyy'); 94 95 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, 96 '', "file=xxx.yyy\n"); 97 98 unlink('xxx.yyy'); 99 100 run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!, 101 '', "file=\n"); 102 91 103 1; -
trunk/src/kmk/tests/scripts/functions/word
r969 r3140 57 57 wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))', 58 58 'word-e1', 59 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''. Stop.",59 "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''. Stop.", 60 60 512); 61 61 62 62 run_make_test(undef, 63 63 'word-e2', 64 "#MAKEFILE#:4: *** non-numeric first argument to `word' function: 'abc '. Stop.",64 "#MAKEFILE#:4: *** non-numeric first argument to 'word' function: 'abc '. Stop.", 65 65 512); 66 66 67 67 run_make_test(undef, 68 68 'word-e3', 69 "#MAKEFILE#:5: *** non-numeric first argument to `word' function: '1a'. Stop.",69 "#MAKEFILE#:5: *** non-numeric first argument to 'word' function: '1a'. Stop.", 70 70 512); 71 71 72 72 run_make_test(undef, 73 73 'wordlist-e1', 74 "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''. Stop.",74 "#MAKEFILE#:7: *** non-numeric first argument to 'wordlist' function: ''. Stop.", 75 75 512); 76 76 77 77 run_make_test(undef, 78 78 'wordlist-e2', 79 "#MAKEFILE#:8: *** non-numeric first argument to `wordlist' function: 'abc '. Stop.",79 "#MAKEFILE#:8: *** non-numeric first argument to 'wordlist' function: 'abc '. Stop.", 80 80 512); 81 81 82 82 run_make_test(undef, 83 83 'wordlist-e3', 84 "#MAKEFILE#:9: *** non-numeric second argument to `wordlist' function: ' 12a '. Stop.",84 "#MAKEFILE#:9: *** non-numeric second argument to 'wordlist' function: ' 12a '. Stop.", 85 85 512); 86 86 … … 95 95 wordlist-e: ; @echo $(WL)', 96 96 'word-e x=', 97 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''. Stop.",97 "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''. Stop.", 98 98 512); 99 99 100 100 run_make_test(undef, 101 101 'word-e x=abc', 102 "#MAKEFILE#:3: *** non-numeric first argument to `word' function: 'abc'. Stop.",102 "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: 'abc'. Stop.", 103 103 512); 104 104 105 105 run_make_test(undef, 106 106 'word-e x=0', 107 "#MAKEFILE#:3: *** first argument to `word' function must be greater than 0. Stop.",107 "#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0. Stop.", 108 108 512); 109 109 110 110 run_make_test(undef, 111 111 'wordlist-e s= e=', 112 "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: ''. Stop.",112 "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: ''. Stop.", 113 113 512); 114 114 115 115 run_make_test(undef, 116 116 'wordlist-e s=abc e=', 117 "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: 'abc'. Stop.",117 "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: 'abc'. Stop.", 118 118 512); 119 119 120 120 run_make_test(undef, 121 121 'wordlist-e s=4 e=12a', 122 "#MAKEFILE#:4: *** non-numeric second argument to `wordlist' function: '12a'. Stop.",122 "#MAKEFILE#:4: *** non-numeric second argument to 'wordlist' function: '12a'. Stop.", 123 123 512); 124 124 125 125 run_make_test(undef, 126 126 'wordlist-e s=0 e=12', 127 "#MAKEFILE#:4: *** invalid first argument to `wordlist' function: `0'. Stop.",127 "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'. Stop.", 128 128 512); 129 129
Note:
See TracChangeset
for help on using the changeset viewer.