summaryrefslogtreecommitdiff
path: root/tests/scripts/variables
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scripts/variables')
-rw-r--r--tests/scripts/variables/DEFAULT_GOAL2
-rw-r--r--tests/scripts/variables/GNUMAKEFLAGS42
-rw-r--r--tests/scripts/variables/LIBPATTERNS2
-rw-r--r--tests/scripts/variables/MAKE4
-rw-r--r--tests/scripts/variables/MAKEFLAGS26
-rw-r--r--tests/scripts/variables/MAKE_RESTARTS4
-rw-r--r--tests/scripts/variables/SHELL19
-rw-r--r--tests/scripts/variables/define56
-rw-r--r--tests/scripts/variables/flavors20
-rw-r--r--tests/scripts/variables/private44
-rw-r--r--tests/scripts/variables/special2
11 files changed, 195 insertions, 26 deletions
diff --git a/tests/scripts/variables/DEFAULT_GOAL b/tests/scripts/variables/DEFAULT_GOAL
index 1c06506..8188ce7 100644
--- a/tests/scripts/variables/DEFAULT_GOAL
+++ b/tests/scripts/variables/DEFAULT_GOAL
@@ -42,7 +42,7 @@ run_make_test('
.DEFAULT_GOAL = foo
',
'',
-'#MAKE#: *** No rule to make target `foo\'. Stop.',
+"#MAKE#: *** No rule to make target 'foo'. Stop.",
512);
diff --git a/tests/scripts/variables/GNUMAKEFLAGS b/tests/scripts/variables/GNUMAKEFLAGS
new file mode 100644
index 0000000..e9c0d55
--- /dev/null
+++ b/tests/scripts/variables/GNUMAKEFLAGS
@@ -0,0 +1,42 @@
+# -*-perl-*-
+
+$description = "Test proper behavior of GNUMAKEFLAGS";
+
+# Accept flags from GNUMAKEFLAGS as well as MAKEFLAGS
+# Results always go in MAKEFLAGS
+
+$extraENV{'GNUMAKEFLAGS'} = '-e -r -R';
+
+run_make_test(q!
+all: ; @echo $(MAKEFLAGS)
+!,
+ '', 'erR');
+
+# Long arguments mean everything is prefixed with "-"
+
+$extraENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace';
+
+run_make_test(q!
+all: ; @echo $(MAKEFLAGS)
+!,
+ '', "#MAKEFILE#:2: target 'all' does not exist
+echo erR --trace --no-print-directory
+erR --trace --no-print-directory");
+
+# Verify that re-exec / recursion doesn't duplicate flags from GNUMAKEFLAGS
+
+unlink('x.mk');
+
+$extraENV{GNUMAKEFLAGS} = '-Itst/bad -Oline';
+
+run_make_test(q!
+recurse: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; #MAKEPATH# -f #MAKEFILE# all
+all: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS
+-include x.mk
+x.mk: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; echo > $@
+!,
+ "", "x.mk\nMAKEFLAGS = -Itst/bad -Oline\nGNUMAKEFLAGS =\nrecurse\nMAKEFLAGS = -Itst/bad -Oline\nGNUMAKEFLAGS =\n#MAKE#[1]: Entering directory '#PWD#'\nall\nMAKEFLAGS = w -Itst/bad -Oline\nGNUMAKEFLAGS =\n#MAKE#[1]: Leaving directory '#PWD#'\n");
+
+unlink('x.mk');
+
+1;
diff --git a/tests/scripts/variables/LIBPATTERNS b/tests/scripts/variables/LIBPATTERNS
index 826f2fa..9182954 100644
--- a/tests/scripts/variables/LIBPATTERNS
+++ b/tests/scripts/variables/LIBPATTERNS
@@ -20,7 +20,7 @@ run_make_test('
.LIBPATTERNS = mtest_foo.a mtest_%.a
all: -lfoo ; @echo "build $@ from $<"
',
- '', "#MAKE#: .LIBPATTERNS element `mtest_foo.a' is not a pattern
+ '', "#MAKE#: .LIBPATTERNS element 'mtest_foo.a' is not a pattern
build all from mtest_foo.a\n");
# TEST 2: target-specific override
diff --git a/tests/scripts/variables/MAKE b/tests/scripts/variables/MAKE
index d1081da..dc62160 100644
--- a/tests/scripts/variables/MAKE
+++ b/tests/scripts/variables/MAKE
@@ -16,8 +16,8 @@ foo:
!,
'',
"#MAKEPATH#\n#MAKEPATH# -f #MAKEFILE# foo\n"
- . "#MAKE#[1]: Entering directory `#PWD#'\n"
- . "#MAKEPATH#\n#MAKE#[1]: Leaving directory `#PWD#'\n");
+ . "#MAKE#[1]: Entering directory '#PWD#'\n"
+ . "#MAKEPATH#\n#MAKE#[1]: Leaving directory '#PWD#'\n");
rmfiles("foo");
diff --git a/tests/scripts/variables/MAKEFLAGS b/tests/scripts/variables/MAKEFLAGS
index 0b567e8..8a5d0f6 100644
--- a/tests/scripts/variables/MAKEFLAGS
+++ b/tests/scripts/variables/MAKEFLAGS
@@ -1,4 +1,4 @@
-# -*-perl-*-
+# -*-perl-*-
$description = "Test proper behavior of MAKEFLAGS";
@@ -8,36 +8,34 @@ $details = "DETAILS";
run_make_test(q!
all: ; @echo $(MAKEFLAGS)
!,
- '-e -r -R', 'Rre');
+ '-e -r -R', 'erR');
# Long arguments mean everything is prefixed with "-"
run_make_test(q!
all: ; @echo $(MAKEFLAGS)
!,
- '--no-print-directory -e -r -R', '--no-print-directory -Rre');
+ '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: target 'all' does not exist
+echo erR --trace --no-print-directory
+erR --trace --no-print-directory");
-if ($all_tests) {
- # Recursive invocations of make should accumulate MAKEFLAGS values.
- # Savannah bug #2216
- run_make_test(q!
+# Recursive invocations of make should accumulate MAKEFLAGS values.
+# Savannah bug #2216
+run_make_test(q!
MSG = Fails
all:
@echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
@MSG=Works $(MAKE) -e -f #MAKEFILE# jump
jump:
- @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
+ @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
@$(MAKE) -f #MAKEFILE# print
print:
- @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
- @echo $(MSG)
+ @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
.PHONY: all jump print
!,
'--no-print-directory',
'all: MAKEFLAGS= --no-print-directory
-jump: MAKEFLAGS= --no-print-directory -e
-print: MAKEFLAGS= --no-print-directory -e
-Works');
-}
+jump Works: MAKEFLAGS=e --no-print-directory
+print Works: MAKEFLAGS=e --no-print-directory');
1;
diff --git a/tests/scripts/variables/MAKE_RESTARTS b/tests/scripts/variables/MAKE_RESTARTS
index 53ab738..ef8e368 100644
--- a/tests/scripts/variables/MAKE_RESTARTS
+++ b/tests/scripts/variables/MAKE_RESTARTS
@@ -52,10 +52,10 @@ MAKE_RESTARTS=1
foo.x:1: bar.x: No such file or directory
MAKE_RESTARTS=2
recurse MAKE_RESTARTS=
+#MAKE#[1]: Entering directory '#PWD#'
MAKE_RESTARTS=
-#MAKE#[1]: Entering directory `#PWD#'
all MAKE_RESTARTS=
-#MAKE#[1]: Leaving directory `#PWD#'");
+#MAKE#[1]: Leaving directory '#PWD#'");
rmfiles('foo.x', 'bar.x');
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index 7b7e7fe..1d01ba3 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -70,6 +70,22 @@ all: ; \@$script
!,
'', $out);
+# Do it again but add spaces to SHELLFLAGS
+
+# Some shells (*shakes fist at Solaris*) cannot handle multiple flags in
+# separate arguments.
+my $t = `/bin/sh -e -c true 2>/dev/null`;
+my $multi_ok = $? == 0;
+
+if ($multi_ok) {
+ $flags = '-x -c';
+ run_make_test(qq!
+.SHELLFLAGS = $flags
+all: ; \@$script
+!,
+ '', $out);
+}
+
# We can't just use "false" because on different systems it provides a
# different exit code--once again Solaris: false exits with 255 not 1
$script = 'true; false; true';
@@ -81,6 +97,7 @@ run_make_test(qq!
.SHELLFLAGS = $flags
all: ; \@$script
!,
- '', "$out#MAKE#: *** [all] Error $err\n", 512);
+ '', "$out#MAKEFILE#:3: recipe for target 'all' failed
+#MAKE#: *** [all] Error $err\n", 512);
1;
diff --git a/tests/scripts/variables/define b/tests/scripts/variables/define
index f91519e..7324cbc 100644
--- a/tests/scripts/variables/define
+++ b/tests/scripts/variables/define
@@ -30,6 +30,10 @@ define simple :=
@echo $(FOO)
endef
+define posix ::=
+@echo $(FOO)
+endef
+
append = @echo a
define append +=
@@ -49,10 +53,54 @@ FOO = there
all: ; $(multi)
$(simple)
+ $(posix)
+ $(append)
+ $(cond)
+',
+ '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
+
+# TEST 1a: Various new-style define/endef, with no spaces
+
+run_make_test('
+FOO = foo
+
+define multi=
+echo hi
+@echo $(FOO)
+endef # this is the end
+
+define simple:=
+@echo $(FOO)
+endef
+
+define posix::=
+@echo $(FOO)
+endef
+
+append = @echo a
+
+define append+=
+
+@echo b
+endef
+
+define cond?= # this is a conditional
+@echo first
+endef
+
+define cond?=
+@echo second
+endef
+
+FOO = there
+
+all: ; $(multi)
+ $(simple)
+ $(posix)
$(append)
$(cond)
',
- '', "echo hi\nhi\nthere\nfoo\na\nb\nfirst\n");
+ '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
# TEST 2: define in true section of conditional (containing conditional)
@@ -112,7 +160,7 @@ ouch
endef
all: ; @echo ok
',
- '', "#MAKEFILE#:3: extraneous text after `define' directive\nok\n");
+ '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n");
# TEST 7: NEGATIVE: extra text after endef
@@ -123,7 +171,7 @@ ouch
endef $(NAME)
all: ; @echo ok
',
- '', "#MAKEFILE#:5: extraneous text after `endef' directive\nok\n");
+ '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n");
# TEST 8: NEGATIVE: missing endef
@@ -134,7 +182,7 @@ define NAME =
ouch
endef$(NAME)
',
- '', "#MAKEFILE#:4: *** missing `endef', unterminated `define'. Stop.\n", 512);
+ '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'. Stop.\n", 512);
# -------------------------
# Make sure that prefix characters apply properly to define/endef values.
diff --git a/tests/scripts/variables/flavors b/tests/scripts/variables/flavors
index 92feed6..ba133ea 100644
--- a/tests/scripts/variables/flavors
+++ b/tests/scripts/variables/flavors
@@ -73,4 +73,24 @@ all: ; @echo $(foo)
',
'', "Hello\n");
+# TEST 6: Simple using POSIX syntax
+run_make_test('
+bar = Goodbye
+foo ::= $(bar)
+bar = ${ugh}
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Goodbye\n");
+
+# TEST 7: POSIX syntax no spaces
+run_make_test('
+bar = Goodbye
+foo::=$(bar)
+bar = ${ugh}
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Goodbye\n");
+
1;
diff --git a/tests/scripts/variables/private b/tests/scripts/variables/private
index b4baf5f..8967ffb 100644
--- a/tests/scripts/variables/private
+++ b/tests/scripts/variables/private
@@ -75,4 +75,48 @@ a b: ; @echo $@=$(private)
',
'', "b=a\na=a\n");
+# 9: make sure private suppresses inheritance
+run_make_test(q!
+DEFS = FOO
+all: bar1
+bar1: private DEFS += 1
+bar3: private DEFS += 3
+bar1: bar2
+bar2: bar3
+bar1 bar2 bar3: ; @echo '$@: $(DEFS)'
+!,
+ '', "bar3: FOO 3\nbar2: FOO\nbar1: FOO 1\n");
+
+# 10: Test append with pattern-specific variables and private
+
+run_make_test(q!
+IA = global
+PA = global
+PS = global
+S = global
+PS = global
+SV = global
+b%: IA += b%
+b%: private PA += b%
+b%: private PS = b%
+bar: all
+bar: IA += bar
+bar: private PA += bar
+bar: private PS = bar
+a%: IA += a%
+a%: private PA += a%
+a%: private PS = a%
+all: IA += all
+all: private PA += all
+all: private PS = all
+
+bar all: ; @echo '$@: IA=$(IA)'; echo '$@: PA=$(PA)'; echo '$@: PS=$(PS)'
+!,
+ '', "all: IA=global b% bar a% all
+all: PA=global a% all
+all: PS=all
+bar: IA=global b% bar
+bar: PA=global b% bar
+bar: PS=bar\n");
+
1;
diff --git a/tests/scripts/variables/special b/tests/scripts/variables/special
index a1e15c2..4637b2a 100644
--- a/tests/scripts/variables/special
+++ b/tests/scripts/variables/special
@@ -53,7 +53,7 @@ all:
# Test the .RECIPEPREFIX variable
&run_make_test('
define foo
-: foo-one \
+: foo-one\
foo-two
: foo-three
: foo-four