summaryrefslogtreecommitdiff
path: root/tests/scripts/features
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scripts/features')
-rw-r--r--tests/scripts/features/order_only104
-rw-r--r--tests/scripts/features/se_explicit24
-rw-r--r--tests/scripts/features/se_statpat4
-rw-r--r--tests/scripts/features/statipattrules65
4 files changed, 83 insertions, 114 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;