summaryrefslogtreecommitdiff
path: root/tests/scripts
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2009-06-04 06:30:27 +0000
committerPaul Smith <psmith@gnu.org>2009-06-04 06:30:27 +0000
commit81f3e4babd128f6740d05b371122762924522fb6 (patch)
treeeeb19eaf947791c834620ff72c9b80e77d9fcc8b /tests/scripts
parent5b4d419476e9fbda8ea26017f6ec15956d103ed9 (diff)
downloadgunmake-81f3e4babd128f6740d05b371122762924522fb6.tar.gz
- Modify access of config and gnulib Savannah modules to use GIT
- Fix Savannah bug #24655. - Fix Savannah bug #24588. - Fix Savannah bug #24277. - Fix Savannah bug #25697. - Fix Savannah bug #25694. - Fix Savannah bug #25460. - Fix Savannah bug #26207. - Fix Savannah bug #25712. - Fix Savannah bug #26593. - Fix various doc issues.
Diffstat (limited to 'tests/scripts')
-rw-r--r--tests/scripts/features/override55
-rw-r--r--tests/scripts/features/patspecific_vars10
-rw-r--r--tests/scripts/features/patternrules15
-rw-r--r--tests/scripts/features/se_explicit7
-rw-r--r--tests/scripts/features/targetvars18
-rw-r--r--tests/scripts/variables/DEFAULT_GOAL9
-rw-r--r--tests/scripts/variables/flavors209
7 files changed, 140 insertions, 183 deletions
diff --git a/tests/scripts/features/override b/tests/scripts/features/override
index 23e4f2b..fff6c4e 100644
--- a/tests/scripts/features/override
+++ b/tests/scripts/features/override
@@ -1,34 +1,45 @@
-$description = "The following test creates a makefile to ...";
+# -*-perl-*-
-$details = "";
-
-open(MAKEFILE,"> $makefile");
-
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE "override define foo\n"
- ."\@echo First comes the definition.\n"
- ."\@echo Then comes the override.\n"
- ."endef\n"
- ."all: \n"
- ."\t\$(foo)\n";
+$description = "Test the override directive on variable assignments.";
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
+$details = "";
-&run_make_with_options($makefile,"foo=Hello",&get_logfile);
+# TEST 0: Basic override
-# Create the answer to what should be produced by this Makefile
-$answer = "First comes the definition.\n"
- ."Then comes the override.\n";
+run_make_test('
+X = start
+override recur = $(X)
+override simple := $(X)
+X = end
+all: ; @echo "$(recur) $(simple)"
+',
+ 'recur=I simple=J', "end start\n");
-&compare_output($answer,&get_logfile(1));
+# TEST 1: Override with append
-1;
+run_make_test('
+X += X1
+override X += X2
+override Y += Y1
+Y += Y2
+all: ; @echo "$(X) $(Y)"
+',
+ '', "X1 X2 Y1\n");
+# TEST 2: Override with append to the command line
+run_make_test(undef, 'X=C Y=C', "C X2 C Y1\n");
+# Test override of define/endef
+run_make_test('
+override define foo
+@echo First comes the definition.
+@echo Then comes the override.
+endef
+all: ; $(foo)
+',
+ 'foo=Hello', "First comes the definition.\nThen comes the override.\n");
+1;
diff --git a/tests/scripts/features/patspecific_vars b/tests/scripts/features/patspecific_vars
index 20c1cfc..355e86d 100644
--- a/tests/scripts/features/patspecific_vars
+++ b/tests/scripts/features/patspecific_vars
@@ -120,5 +120,15 @@ run_make_test(undef, # reuse previous makefile
'normal: global: new $t pattern: good $t inherit: good $t;
pattrn: global: new $t pattern: good $t inherit: good $t;');
+# TEST #8: override in pattern-specific variables
+
+run_make_test('
+a%: override FOO += f1
+a%: FOO += f2
+ab: ; @echo "$(FOO)"
+',
+ '', "f1\n");
+
+run_make_test(undef, 'FOO=C', "C f1\n");
1;
diff --git a/tests/scripts/features/patternrules b/tests/scripts/features/patternrules
index 53ec704..35f155a 100644
--- a/tests/scripts/features/patternrules
+++ b/tests/scripts/features/patternrules
@@ -145,5 +145,20 @@ echo foo.c foo.h >foo.o');
unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
+# TEST #5: make sure both prefix and suffix patterns work with multiple
+# target patterns (Savannah bug #26593).
+#
+run_make_test('
+all: foo.s1 foo.s2 p1.foo p2.foo
+
+p1.% p2.%: %.orig
+ @echo $@
+%.s1 %.s2: %.orig
+ @echo $@
+
+.PHONY: foo.orig
+',
+ '', "foo.s1\np1.foo\n");
+
# 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 01860a9..b0342c7 100644
--- a/tests/scripts/features/se_explicit
+++ b/tests/scripts/features/se_explicit
@@ -123,5 +123,12 @@ baz.1
baz.2
');
+# TEST #4: eval in a context where there is no reading_file
+run_make_test('
+.SECONDEXPANSION:
+all : $$(eval $$(info test))
+', '', "test\n#MAKE#: Nothing to be done for `all'.\n");
+
+
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/features/targetvars b/tests/scripts/features/targetvars
index ad0766c..3864bf8 100644
--- a/tests/scripts/features/targetvars
+++ b/tests/scripts/features/targetvars
@@ -219,12 +219,24 @@ rmdir('t1');
# Test appending to a simple variable containing a "$": avoid a
# double-expansion. See Savannah bug #15913.
-run_make_test("
-VAR := \$\$FOO
+run_make_test('
+VAR := $$FOO
foo: VAR += BAR
-foo: ; \@echo '\$(VAR)'",
+foo: ; @echo '."'".'$(VAR)'."'".'
+',
'', '$FOO BAR');
+# TEST #19: Override with append variables
+
+run_make_test('
+a: override FOO += f1
+a: FOO += f2
+a: ; @echo "$(FOO)"
+',
+ '', "f1\n");
+
+run_make_test(undef, 'FOO=C', "C f1\n");
+
# TEST #19: Test define/endef variables as target-specific vars
# run_make_test('
diff --git a/tests/scripts/variables/DEFAULT_GOAL b/tests/scripts/variables/DEFAULT_GOAL
index 897bd4a..1c06506 100644
--- a/tests/scripts/variables/DEFAULT_GOAL
+++ b/tests/scripts/variables/DEFAULT_GOAL
@@ -73,6 +73,15 @@ $(call make-rule)
'',
'foo');
+# TEST #5: .DEFAULT_GOAL containing just whitespace (Savannah bug #25697)
+
+run_make_test('
+N =
+.DEFAULT_GOAL = $N $N # Just whitespace
+
+foo: ; @echo "boo"
+',
+ '', "#MAKE#: *** No targets. Stop.\n", 512);
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/variables/flavors b/tests/scripts/variables/flavors
index 3ceac5e..92feed6 100644
--- a/tests/scripts/variables/flavors
+++ b/tests/scripts/variables/flavors
@@ -4,180 +4,73 @@ $description = "Test various flavors of make variable setting.";
$details = "";
-open(MAKEFILE, "> $makefile");
+# TEST 0: Recursive
-# The Contents of the MAKEFILE ...
-
-print MAKEFILE <<'EOF';
+run_make_test('
+ugh = Goodbye
foo = $(bar)
bar = ${ugh}
ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Hello\n");
-all: multi ; @echo $(foo)
-
-multi: ; $(multi)
-
-x := foo
-y := $(x) bar
-x := later
-
-nullstring :=
-space := $(nullstring) $(nullstring)
-
-next: ; @echo $x$(space)$y
-
-define multi
-@echo hi
-echo there
-endef
-
-ifdef BOGUS
-define
-@echo error
-endef
-endif
-
-define outer
- define inner
- A = B
- endef
-endef
-
-$(eval $(outer))
-
-outer: ; @echo $(inner)
-
-EOF
-
-# END of Contents of MAKEFILE
-
-close(MAKEFILE);
-
-# TEST #1
-# -------
-
-&run_make_with_options($makefile, "", &get_logfile);
-$answer = "hi\necho there\nthere\nHello\n";
-&compare_output($answer, &get_logfile(1));
-
-# TEST #2
-# -------
-
-&run_make_with_options($makefile, "next", &get_logfile);
-$answer = "later foo bar\n";
-&compare_output($answer, &get_logfile(1));
-
-# TEST #3
-# -------
-
-&run_make_with_options($makefile, "BOGUS=true", &get_logfile, 512);
-$answer = "$makefile:24: *** empty variable name. Stop.\n";
-&compare_output($answer, &get_logfile(1));
-
-# TEST #4
-# -------
-
-&run_make_with_options($makefile, "outer", &get_logfile);
-$answer = "A = B\n";
-&compare_output($answer, &get_logfile(1));
-
-# Clean up from "old style" testing. If all the above tests are converted to
-# run_make_test() syntax than this line can be removed.
-$makefile = undef;
-
-# -------------------------
-# Make sure that prefix characters apply properly to define/endef values.
-#
-# There's a bit of oddness here if you try to use a variable to hold the
-# prefix character for a define. Even though something like this:
-#
-# define foo
-# echo bar
-# endef
-#
-# all: ; $(V)$(foo)
-#
-# (where V=@) can be seen by the user to be obviously different than this:
-#
-# define foo
-# $(V)echo bar
-# endef
-#
-# all: ; $(foo)
-#
-# and the user thinks it should behave the same as when the "@" is literal
-# instead of in a variable, that can't happen because by the time make
-# expands the variables for the command line and sees it begins with a "@" it
-# can't know anymore whether the prefix character came before the variable
-# reference or was included in the first line of the variable reference.
-
-# TEST #5
-# -------
+# TEST 1: Simple
run_make_test('
-define FOO
-$(V1)echo hello
-$(V2)echo world
-endef
-all: ; @$(FOO)
-', '', 'hello
-world');
-
-# TEST #6
-# -------
-
-run_make_test(undef, 'V1=@ V2=@', 'hello
-world');
+bar = Goodbye
+foo := $(bar)
+bar = ${ugh}
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Goodbye\n");
-# TEST #7
-# -------
+# TEST 2: Append to recursive
run_make_test('
-define FOO
-$(V1)echo hello
-$(V2)echo world
-endef
-all: ; $(FOO)
-', 'V1=@', 'hello
-echo world
-world');
+foo = Hello
+ugh = Goodbye
+foo += $(bar)
+bar = ${ugh}
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Hello Hello\n");
-# TEST #8
-# -------
+# TEST 3: Append to simple
-run_make_test(undef, 'V2=@', 'echo hello
-hello
-world');
+run_make_test('
+foo := Hello
+ugh = Goodbye
+bar = ${ugh}
+foo += $(bar)
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Hello Goodbye\n");
-# TEST #9
-# -------
+# TEST 4: Conditional pre-set
-run_make_test(undef, 'V1=@ V2=@', 'hello
-world');
+run_make_test('
+foo = Hello
+ugh = Goodbye
+bar = ${ugh}
+foo ?= $(bar)
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Hello\n");
-# TEST #10
-# -------
-# Test the basics; a "@" internally to the variable applies to only one line.
-# A "@" before the variable applies to the entire variable.
+# TEST 5: Conditional unset
run_make_test('
-define FOO
-@echo hello
-echo world
-endef
-define BAR
-echo hello
-echo world
-endef
-
-all: foo bar
-foo: ; $(FOO)
-bar: ; @$(BAR)
-', '', 'hello
-echo world
-world
-hello
-world
-');
+ugh = Goodbye
+bar = ${ugh}
+foo ?= $(bar)
+ugh = Hello
+all: ; @echo $(foo)
+',
+ '', "Hello\n");
1;