diff options
Diffstat (limited to 'tests/scripts')
-rw-r--r-- | tests/scripts/features/order_only | 104 | ||||
-rw-r--r-- | tests/scripts/features/se_explicit | 24 | ||||
-rw-r--r-- | tests/scripts/features/se_statpat | 4 | ||||
-rw-r--r-- | tests/scripts/features/statipattrules | 65 | ||||
-rw-r--r-- | tests/scripts/misc/general4 | 25 | ||||
-rw-r--r-- | tests/scripts/variables/automatic | 7 |
6 files changed, 103 insertions, 126 deletions
diff --git a/tests/scripts/features/order_only b/tests/scripts/features/order_only index 82a7253..4ebdc2b 100644 --- a/tests/scripts/features/order_only +++ b/tests/scripts/features/order_only @@ -5,9 +5,18 @@ $details = "\ Create makefiles with various combinations of normal and order-only prerequisites and ensure they behave properly. Test the \$| variable."; -open(MAKEFILE,"> $makefile"); +# TEST #0 -- Basics -print MAKEFILE <<'EOF'; +run_make_test(' +%r: | baz ; @echo $< $^ $| +bar: foo +foo:;@: +baz:;@:', + '', "foo foo baz\n"); + +# TEST #1 -- First try: the order-only prereqs need to be built. + +run_make_test(q! foo: bar | baz @echo '$$^ = $^' @echo '$$| = $|' @@ -16,34 +25,19 @@ foo: bar | baz .PHONY: baz bar baz: - touch $@ -EOF - -close(MAKEFILE); - - -# TEST #1 -- just the syntax - -&run_make_with_options($makefile, "", &get_logfile); -$answer = "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"; -&compare_output($answer,&get_logfile(1)); + touch $@!, + '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"); # TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated -&run_make_with_options($makefile, "", &get_logfile); -$answer = "touch baz\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '', "touch baz\n"); unlink(qw(foo bar baz)); -# Test prereqs that are both order and non-order - -$makefile2 = &get_tmpfile; - -open(MAKEFILE,"> $makefile2"); +# TEST #3 -- Make sure the order-only prereq was promoted to normal. -print MAKEFILE <<'EOF'; +run_make_test(q! foo: bar | baz @echo '$$^ = $^' @echo '$$| = $|' @@ -54,33 +48,21 @@ foo: baz .PHONY: baz bar baz: - touch $@ -EOF - -close(MAKEFILE); - -# TEST #3 -- Make sure the order-only prereq was promoted to normal. - -&run_make_with_options($makefile2, "", &get_logfile); -$answer = "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"; -&compare_output($answer,&get_logfile(1)); + touch $@!, + '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); # TEST #4 -- now we do it again -&run_make_with_options($makefile2, "", &get_logfile); -$answer = "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); unlink(qw(foo bar baz)); # Test empty normal prereqs -$makefile3 = &get_tmpfile; - -open(MAKEFILE,"> $makefile3"); +# TEST #5 -- make sure the parser was correct. -print MAKEFILE <<'EOF'; +run_make_test(q! foo:| baz @echo '$$^ = $^' @echo '$$| = $|' @@ -89,33 +71,20 @@ foo:| baz .PHONY: baz baz: - touch $@ -EOF - -close(MAKEFILE); - -# TEST #5 -- make sure the parser was correct. - -&run_make_with_options($makefile3, "", &get_logfile); -$answer = "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"; -&compare_output($answer,&get_logfile(1)); - + touch $@!, + '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"); # TEST #6 -- now we do it again: this time foo won't be built -&run_make_with_options($makefile3, "", &get_logfile); -$answer = "touch baz\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '', "touch baz\n"); unlink(qw(foo baz)); # Test order-only in pattern rules -$makefile4 = &get_tmpfile; - -open(MAKEFILE,"> $makefile4"); +# TEST #7 -- make sure the parser was correct. -print MAKEFILE <<'EOF'; +run_make_test(q! %.w : %.x | baz @echo '$$^ = $^' @echo '$$| = $|' @@ -125,22 +94,13 @@ all: foo.w .PHONY: baz foo.x baz: - touch $@ -EOF - -close(MAKEFILE); - -# TEST #7 -- make sure the parser was correct. - -&run_make_with_options($makefile4, "", &get_logfile); -$answer = "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"; -&compare_output($answer,&get_logfile(1)); + touch $@!, + '', + "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"); # TEST #8 -- now we do it again: this time foo.w won't be built -&run_make_with_options($makefile4, "", &get_logfile); -$answer = "touch baz\n"; -&compare_output($answer,&get_logfile(1)); +run_make_test(undef, '', "touch baz\n"); unlink(qw(foo.w foo.x baz)); @@ -151,8 +111,8 @@ run_make_test(' %r: | baz ; @echo $< $^ $| bar: foo foo:;@: -baz:;@: -', '', "foo foo baz\n"); +baz:;@:', + '', "foo foo baz\n"); 1; diff --git a/tests/scripts/features/se_explicit b/tests/scripts/features/se_explicit index 0e696be..01860a9 100644 --- a/tests/scripts/features/se_explicit +++ b/tests/scripts/features/se_explicit @@ -3,9 +3,29 @@ $description = "Test second expansion in ordinary rules."; $details = ""; -# Test #1: automatic variables. +# TEST #0: Test handing of '$' in prerequisites with and without second +# expansion. + +run_make_test(q! +ifdef SE + .SECONDEXPANSION: +endif +foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^' +PRE = one two +bar$$baz: $$(PRE) +baraz: $$(PRE) +PRE = three four +.DEFAULT: ; @echo '$@' +!, + '', + "\$\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz"); + +run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz"); + +# TEST #1: automatic variables. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ foo: bar baz @@ -41,6 +61,7 @@ buz.5 # Test #2: target/pattern -specific variables. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ foo.x: $$a $$b @@ -59,6 +80,7 @@ baz # Test #3: order of prerequisites. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ all: foo bar baz diff --git a/tests/scripts/features/se_statpat b/tests/scripts/features/se_statpat index 3c54622..096b240 100644 --- a/tests/scripts/features/se_statpat +++ b/tests/scripts/features/se_statpat @@ -6,6 +6,7 @@ $details = ""; # Test #1: automatic variables. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ foo.a foo.b: foo.%: bar.% baz.% @@ -41,6 +42,7 @@ a.6 # Test #2: target/pattern -specific variables. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ foo.x foo.y: foo.%: $$(%_a) $$($$*_b) @@ -60,6 +62,7 @@ baz # Test #3: order of prerequisites. # run_make_test(' +.SECONDEXPANSION: .DEFAULT: ; @echo $@ all: foo.a bar.a baz.a @@ -106,6 +109,7 @@ baz.a.2 # Test #4: Make sure stem triple-expansion does not happen. # run_make_test(' +.SECONDEXPANSION: foo$$bar: f%r: % $$*.1 @echo \'$*\' diff --git a/tests/scripts/features/statipattrules b/tests/scripts/features/statipattrules index 0ca2bb7..429b56a 100644 --- a/tests/scripts/features/statipattrules +++ b/tests/scripts/features/statipattrules @@ -9,79 +9,62 @@ name and the target name with .c. It also does the same thing for another target filtered with .elc and creates a command to emacs a .el file"; -open(MAKEFILE,"> $makefile"); -print MAKEFILE <<'EOF'; -files = foo.elc bar.o lose.o - -$(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@ - -$(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $< -EOF -close(MAKEFILE); - - &touch('bar.c', 'lose.c'); -# TEST #1 +# TEST #0 # ------- -&run_make_with_options($makefile, '', &get_logfile); -$answer = "CC -c bar.c -o bar.o\n"; -&compare_output($answer, &get_logfile(1)); +run_make_test(' +files = foo.elc bar.o lose.o + +$(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@ +$(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $< +', + '', + 'CC -c bar.c -o bar.o'); -# TEST #2 +# TEST #1 # ------- -&run_make_with_options($makefile, 'lose.o', &get_logfile); -$answer = "CC -c lose.c -o lose.o\n"; -&compare_output($answer, &get_logfile(1)); +run_make_test(undef, 'lose.o', 'CC -c lose.c -o lose.o'); -# TEST #3 +# TEST #2 # ------- &touch("foo.el"); -&run_make_with_options($makefile, 'foo.elc', &get_logfile); -$answer = "emacs foo.el\n"; -&compare_output($answer, &get_logfile(1)); - +run_make_test(undef, 'foo.elc', 'emacs foo.el'); +# Clean up after the first tests. unlink('foo.el', 'bar.c', 'lose.c'); -# TEST #4 -- PR/1670: don't core dump on invalid static pattern rules +# TEST #3 -- PR/1670: don't core dump on invalid static pattern rules # ------- -$makefile2 = &get_tmpfile; -open(MAKEFILE, "> $makefile2"); -print MAKEFILE "foo: foo%: % ; \@echo \$@\n"; -close(MAKEFILE); +run_make_test(' +.DEFAULT: ; @echo $@ +foo: foo%: % %.x % % % y.% % ; @echo $@ +', + '', ".x\ny.\nfoo"); -&run_make_with_options($makefile2, '', &get_logfile); -$answer = "foo\n"; -&compare_output($answer, &get_logfile(1)); -# TEST #5 -- bug #12180: core dump on a stat pattern rule with an empty +# TEST #4 -- bug #12180: core dump on a stat pattern rule with an empty # prerequisite list. -# run_make_test(' foo.x bar.x: %.x : ; @echo $@ ', -'', -'foo.x -'); + '', 'foo.x'); -# TEST #6 -- bug #13881: double colon static pattern rule does not +# TEST #5 -- bug #13881: double colon static pattern rule does not # substitute %. -# run_make_test(' foo.bar:: %.bar: %.baz foo.baz: ;@: ', -'', -''); + '', ''); 1; diff --git a/tests/scripts/misc/general4 b/tests/scripts/misc/general4 index 63320e2..0b5c94a 100644 --- a/tests/scripts/misc/general4 +++ b/tests/scripts/misc/general4 @@ -5,8 +5,7 @@ This tests random features of make's algorithms, often somewhat obscure, which have either broken at some point in the past or seem likely to break."; -open(MAKEFILE,"> $makefile"); -print MAKEFILE <<'EOF'; +run_make_test(' # Make sure that subdirectories built as prerequisites are actually handled # properly. @@ -16,13 +15,8 @@ dir/subdir: ; @echo mkdir -p dir/subdir dir/subdir/file.b: dir/subdir ; @echo touch dir/subdir/file.b -dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@ -EOF -close(MAKEFILE); - -&run_make_with_options($makefile,"",&get_logfile); -$answer = "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n"; -&compare_output($answer,&get_logfile(1)); +dir/subdir/%.a: dir/subdir/%.b ; @echo cp $< $@', + '', "mkdir -p dir/subdir\ntouch dir/subdir/file.b\ncp dir/subdir/file.b dir/subdir/file.a\n"); # Test implicit rules @@ -47,4 +41,17 @@ fox: baz 'done bar'); unlink('bar'); + +# Test implicit rules with '$' in the name (see se_implicit) + +run_make_test(q! +%.foo : baz$$bar ; @echo 'done $<' +%.foo : bar$$baz ; @echo 'done $<' +test.foo: +fox: baz +.DEFAULT baz$$bar bar$$baz: ; @echo '$@' +!, + '', + 'done bar'); + 1; diff --git a/tests/scripts/variables/automatic b/tests/scripts/variables/automatic index 484cd16..dc08bd7 100644 --- a/tests/scripts/variables/automatic +++ b/tests/scripts/variables/automatic @@ -27,7 +27,7 @@ $(dir)/bar.y baz.z : ; touch $@ EOF close(MAKEFILE); -# TEST #1 -- simple test +# TEST #0 -- simple test # ------- # Touch these into the past @@ -46,7 +46,7 @@ touch $dir/foo.x\n"; unlink(qw(foo.x bar.y baz.z)); -# TEST #2 -- test the SysV emulation of $$@ etc. +# TEST #1 -- test the SysV emulation of $$@ etc. # ------- $makefile2 = &get_tmpfile; @@ -54,6 +54,7 @@ $makefile2 = &get_tmpfile; open(MAKEFILE, "> $makefile2"); print MAKEFILE "dir = $dir\n"; print MAKEFILE <<'EOF'; +.SECONDEXPANSION: .SUFFIXES: .DEFAULT: ; @echo '$@' @@ -78,7 +79,7 @@ $answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\y\n\$@.y\n$ $answer = "$dir/biz.x\n$dir.x\nbiz.x\n"; &compare_output($answer, &get_logfile(1)); -# TEST #3 -- test for Savannah bug #12320. +# TEST #2 -- test for Savannah bug #12320. # run_make_test(' .SUFFIXES: .b .src |