diff options
author | Paul Smith <psmith@gnu.org> | 2009-09-24 02:41:44 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2009-09-24 02:41:44 +0000 |
commit | 0afbbf8595b6035a5a930399d20320d2e2852d72 (patch) | |
tree | 6c74d485e4d57b2bf41bb5d6afaac1b4569dd554 /tests/scripts/features | |
parent | 3cc351decdd7d53fea0c730fd919163f20706762 (diff) | |
download | gunmake-0afbbf8595b6035a5a930399d20320d2e2852d72.tar.gz |
- Rework secondary expansion so we only defer it if there's a possibility
it might be needed: for most situations we parse prereqs immediately as
we used to. Reduces memory usage.
- Fixes Savannah bug #18622.
Diffstat (limited to 'tests/scripts/features')
-rw-r--r-- | tests/scripts/features/echoing | 99 | ||||
-rw-r--r-- | tests/scripts/features/patternrules | 18 | ||||
-rw-r--r-- | tests/scripts/features/se_explicit | 28 | ||||
-rw-r--r-- | tests/scripts/features/se_implicit | 101 | ||||
-rw-r--r-- | tests/scripts/features/se_statpat | 55 |
5 files changed, 129 insertions, 172 deletions
diff --git a/tests/scripts/features/echoing b/tests/scripts/features/echoing index 2e366cd..40debf5 100644 --- a/tests/scripts/features/echoing +++ b/tests/scripts/features/echoing @@ -1,87 +1,64 @@ -$description = "The following test creates a makefile to test command \n" - ."echoing. It tests that when a command line starts with \n" - ."a '\@', the echoing of that line is suppressed. It also \n" - ."tests the -n option which tells make to ONLY echo the \n" - ."commands and no execution happens. In this case, even \n" - ."the commands with '\@' are printed. Lastly, it tests the \n" - ."-s flag which tells make to prevent all echoing, as if \n" - ."all commands started with a '\@'."; - -$details = "This test is similar to the 'clean' test except that a '\@' has\n" - ."been placed in front of the delete command line. Four tests \n" - ."are run here. First, make is run normally and the first echo\n" - ."command should be executed. In this case there is no '\@' so \n" - ."we should expect make to display the command AND display the \n" - ."echoed message. Secondly, make is run with the clean target, \n" - ."but since there is a '\@' at the beginning of the command, we\n" - ."expect no output; just the deletion of a file which we check \n" - ."for. Third, we give the clean target again except this time\n" - ."we give make the -n option. We now expect the command to be \n" - ."displayed but not to be executed. In this case we need only \n" - ."to check the output since an error message would be displayed\n" - ."if it actually tried to run the delete command again and the \n" - ."file didn't exist. Lastly, we run the first test again with \n" - ."the -s option and check that make did not echo the echo \n" - ."command before printing the message."; +# -*-perl-*- +$description = "The following test creates a makefile to test command +echoing. It tests that when a command line starts with +a '\@', the echoing of that line is suppressed. It also +tests the -n option which tells make to ONLY echo the +commands and no execution happens. In this case, even +the commands with '\@' are printed. Lastly, it tests the +-s flag which tells make to prevent all echoing, as if +all commands started with a '\@'."; + +$details = "This test is similar to the 'clean' test except that a '\@' has +been placed in front of the delete command line. Four tests +are run here. First, make is run normally and the first echo +command should be executed. In this case there is no '\@' so +we should expect make to display the command AND display the +echoed message. Secondly, make is run with the clean target, +but since there is a '\@' at the beginning of the command, we +expect no output; just the deletion of a file which we check +for. Third, we give the clean target again except this time +we give make the -n option. We now expect the command to be +displayed but not to be executed. In this case we need only +to check the output since an error message would be displayed +if it actually tried to run the delete command again and the +file didn't exist. Lastly, we run the first test again with +the -s option and check that make did not echo the echo +command before printing the message.\n"; $example = "EXAMPLE_FILE"; -open(MAKEFILE,"> $makefile"); - -# The Contents of the MAKEFILE ... - -print MAKEFILE "all: \n"; -print MAKEFILE "\techo This makefile did not clean the dir... good\n"; -print MAKEFILE "clean: \n"; -print MAKEFILE "\t\@$delete_command $example\n"; - -# END of Contents of MAKEFILE - -close(MAKEFILE); - -&touch($example); +touch($example); # TEST #1 # ------- -&run_make_with_options($makefile,"",&get_logfile,0); -$answer = "echo This makefile did not clean the dir... good\n" - ."This makefile did not clean the dir... good\n"; -&compare_output($answer,&get_logfile(1)); - +run_make_test(" +all: +\techo This makefile did not clean the dir... good +clean: +\t\@$delete_command $example\n", + '', 'echo This makefile did not clean the dir... good +This makefile did not clean the dir... good'); # TEST #2 # ------- -&run_make_with_options($makefile,"clean",&get_logfile,0); +run_make_test(undef, 'clean', ''); if (-f $example) { $test_passed = 0; + unlink($example); } -&compare_output('',&get_logfile(1)); # TEST #3 # ------- -&run_make_with_options($makefile,"-n clean",&get_logfile,0); -$answer = "$delete_command $example\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '-n clean', "$delete_command $example\n"); # TEST #4 # ------- -&run_make_with_options($makefile,"-s",&get_logfile,0); -$answer = "This makefile did not clean the dir... good\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '-s', "This makefile did not clean the dir... good\n"); 1; - - - - - - - - - diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules index c5bc3db..dcaf0dd 100644 --- a/tests/scripts/features/patternrules +++ b/tests/scripts/features/patternrules @@ -190,5 +190,23 @@ dep: ; @echo $@ '', "dep\nx.t1\nx.t2\nx\nfinal\n"); +# TEST 8: Verify we can remove pattern rules. Savannah bug #18622. + +my @f = (qw(foo.w foo.ch)); +touch(@f); + +run_make_test(q! +CWEAVE := : + +# Disable builtin rules +%.tex : %.w +%.tex : %.w %.ch +!, + 'foo.tex', + "#MAKE#: *** No rule to make target `foo.tex'. Stop.", 512); + +unlink(@f); + + # This tells the test driver that the perl test script executed properly. 1; diff --git a/tests/scripts/features/se_explicit b/tests/scripts/features/se_explicit index 454d494..adf6b33 100644 --- a/tests/scripts/features/se_explicit +++ b/tests/scripts/features/se_explicit @@ -24,9 +24,9 @@ run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz"); # TEST #1: automatic variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' foo: bar baz @@ -39,7 +39,7 @@ foo: $$@.1 \ $$|.5 \ $$*.6 -', +!, '', 'bar baz @@ -60,17 +60,16 @@ buz.5 # Test #2: target/pattern -specific variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' foo.x: $$a $$b foo.x: a := bar %.x: b := baz - -', +!, '', 'bar baz @@ -79,9 +78,9 @@ baz # Test #3: order of prerequisites. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' all: foo bar baz @@ -99,7 +98,7 @@ bar: bar.3 baz: baz.1 baz: baz.2 baz: ; @: -', +!, '', 'foo.1 foo.2 @@ -112,22 +111,23 @@ baz.2 '); # TEST #4: eval in a context where there is no reading_file -run_make_test(' +run_make_test(q! .SECONDEXPANSION: all : $$(eval $$(info test)) -', '', "test\n#MAKE#: Nothing to be done for `all'.\n"); +!, + '', "test\n#MAKE#: Nothing to be done for `all'.\n"); # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new # target/prereq relationships. -run_make_test(' +run_make_test(q! .SECONDEXPANSION: proj1.exe : proj1.o $$(eval $$(test)) define test proj1.o : proj1.c proj1.c: proj1.h endef -', +!, '', "#MAKE#: *** prerequisites cannot be defined in recipes. Stop.\n", 512); # This tells the test driver that the perl test script executed properly. diff --git a/tests/scripts/features/se_implicit b/tests/scripts/features/se_implicit index c2ae648..6db0031 100644 --- a/tests/scripts/features/se_implicit +++ b/tests/scripts/features/se_implicit @@ -11,9 +11,9 @@ $dir =~ s,.*/([^/]+)$,../$1,; # Test #1: automatic variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' foo.a: bar baz @@ -37,9 +37,9 @@ foo.%: 1.$$@ \ 4.biz \ 5.buz \ 6.a: - @echo $@ + @echo '$@' -', +!, '', '1.foo.a 2.bar @@ -60,7 +60,7 @@ buz # Test #2: target/pattern -specific variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: foo.x: @@ -71,20 +71,16 @@ foo.x: x_a := bar %.x: x_b := baz -bar baz: ; @echo $@ - -', -'', -'bar -baz -'); +bar baz: ; @echo '$@' +!, + '', "bar\nbaz\n"); # Test #3: order of prerequisites. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' all: foo bar baz @@ -97,7 +93,7 @@ foo: foo.2 foo: foo.3 -foo.1: ; @echo $@ +foo.1: ; @echo '$@' # Subtest #2 @@ -108,7 +104,7 @@ bar: bar.2 bar: bar.3 -bar.1: ; @echo $@ +bar.1: ; @echo '$@' # Subtest #3 @@ -118,9 +114,8 @@ baz: baz.1 baz: baz.2 %az: ; @: - -', -'', +!, + '', 'foo.1 foo.2 foo.3 @@ -134,20 +129,18 @@ baz.2 # Test #4: stem splitting logic. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: $(dir)/tmp/bar.o: -$(dir)/tmp/foo/bar.c: ; @echo $@ -$(dir)/tmp/bar/bar.c: ; @echo $@ -foo.h: ; @echo $@ +$(dir)/tmp/foo/bar.c: ; @echo '$@' +$(dir)/tmp/bar/bar.c: ; @echo '$@' +foo.h: ; @echo '$@' %.o: $$(addsuffix /%.c,foo bar) foo.h - @echo $@: {$<} $^ - -', -"dir=$dir", -"$dir/tmp/foo/bar.c + @echo '$@: {$<} $^' +!, + "dir=$dir", "$dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h $dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h @@ -156,18 +149,17 @@ $dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h # Test #5: stem splitting logic and order-only prerequisites. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: $(dir)/tmp/foo.o: $(dir)/tmp/foo.c -$(dir)/tmp/foo.c: ; @echo $@ -bar.h: ; @echo $@ +$(dir)/tmp/foo.c: ; @echo '$@' +bar.h: ; @echo '$@' %.o: %.c|bar.h - @echo $@: {$<} {$|} $^ + @echo '$@: {$<} {$|} $^' -', -"dir=$dir", -"$dir/tmp/foo.c +!, + "dir=$dir", "$dir/tmp/foo.c bar.h $dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c "); @@ -175,54 +167,45 @@ $dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c # Test #6: lack of implicit prerequisites. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: foo.o: foo.c -foo.c: ; @echo $@ +foo.c: ; @echo '$@' %.o: - @echo $@: {$<} $^ + @echo '$@: {$<} $^' +!, + '', "foo.c\nfoo.o: {foo.c} foo.c\n"); -', -'', -'foo.c -foo.o: {foo.c} foo.c -'); # Test #7: Test stem from the middle of the name. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: foobarbaz: foo%baz: % $$*.1 - @echo $* + @echo '$*' bar bar.1: - @echo $@ + @echo '$@' +!, + '', "bar\nbar.1\nbar\n"); -', -'', -'bar -bar.1 -bar -'); # Test #8: Make sure stem triple-expansion does not happen. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: foo$$bar: f%r: % $$*.1 - @echo \'$*\' + @echo '$*' oo$$ba oo$$ba.1: - @echo \'$@\' - -', -'', -'oo$ba + @echo '$@' +!, + '', 'oo$ba oo$ba.1 oo$ba '); diff --git a/tests/scripts/features/se_statpat b/tests/scripts/features/se_statpat index 096b240..b1e59e1 100644 --- a/tests/scripts/features/se_statpat +++ b/tests/scripts/features/se_statpat @@ -5,12 +5,11 @@ $details = ""; # Test #1: automatic variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' foo.a foo.b: foo.%: bar.% baz.% - foo.a foo.b: foo.%: biz.% | buz.% foo.a foo.b: foo.%: $$@.1 \ @@ -19,10 +18,8 @@ foo.a foo.b: foo.%: $$@.1 \ $$(addsuffix .4,$$+) \ $$|.5 \ $$*.6 - -', -'', -'bar.a +!, + '', 'bar.a baz.a biz.a buz.a @@ -41,61 +38,45 @@ a.6 # Test #2: target/pattern -specific variables. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' foo.x foo.y: foo.%: $$(%_a) $$($$*_b) foo.x: x_a := bar %.x: x_b := baz - - -', -'', -'bar -baz -'); +!, + '', "bar\nbaz\n"); # Test #3: order of prerequisites. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: -.DEFAULT: ; @echo $@ +.DEFAULT: ; @echo '$@' all: foo.a bar.a baz.a # Subtest #1 -# foo.a foo.b: foo.%: foo.%.1; @: - foo.a foo.b: foo.%: foo.%.2 - foo.a foo.b: foo.%: foo.%.3 # Subtest #2 -# bar.a bar.b: bar.%: bar.%.2 - bar.a bar.b: bar.%: bar.%.1; @: - bar.a bar.b: bar.%: bar.%.3 # Subtest #3 -# baz.a baz.b: baz.%: baz.%.1 - baz.a baz.b: baz.%: baz.%.2 - baz.a baz.b: ; @: - -', -'', -'foo.a.1 +!, + '', 'foo.a.1 foo.a.2 foo.a.3 bar.a.1 @@ -108,17 +89,15 @@ baz.a.2 # Test #4: Make sure stem triple-expansion does not happen. # -run_make_test(' +run_make_test(q! .SECONDEXPANSION: foo$$bar: f%r: % $$*.1 - @echo \'$*\' + @echo '$*' oo$$ba oo$$ba.1: - @echo \'$@\' - -', -'', -'oo$ba + @echo '$@' +!, + '', 'oo$ba oo$ba.1 oo$ba '); |