summaryrefslogtreecommitdiff
path: root/tests/scripts/functions/substitution
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2004-09-21 04:00:31 +0000
committerPaul Smith <psmith@gnu.org>2004-09-21 04:00:31 +0000
commit0799ce730d2404d1cd1d03ce2f4ac07cc079c72e (patch)
tree6b9602199bec0f905f06a7a8f1c7bedb1e65b349 /tests/scripts/functions/substitution
parent08c8105c5468ff743d2f2ff2fdf3b77a6313b53e (diff)
downloadgunmake-0799ce730d2404d1cd1d03ce2f4ac07cc079c72e.tar.gz
Fix some bugs in variable pattern substitution (e.g. $(VAR:A=B)),
reported by Markus Mauhart <qwe123@chello.at>. One was a simple typo; to fix the other we call patsubst_expand() for all instances of variable substitution, even when there is no '%'. We used to call subst_expand() with a special flag set in the latter case, but it didn't work properly in all situations. Easier to just use patsubst_expand() since that's what it is.
Diffstat (limited to 'tests/scripts/functions/substitution')
-rw-r--r--tests/scripts/functions/substitution43
1 files changed, 22 insertions, 21 deletions
diff --git a/tests/scripts/functions/substitution b/tests/scripts/functions/substitution
index 9280dbb..0d2f6a2 100644
--- a/tests/scripts/functions/substitution
+++ b/tests/scripts/functions/substitution
@@ -1,32 +1,33 @@
-$description = "The following test creates a makefile to ...";
+# -*-perl-*-
-$details = "";
-
-open(MAKEFILE,"> $makefile");
+$description = "Test the subst and patsubst functions";
-# The Contents of the MAKEFILE ...
+$details = "";
-print MAKEFILE "foo := a.o b.o c.o\n"
- ."bar := \$(foo:.o=.c)\n"
- ."bar2:= \$(foo:%.o=%.c)\n"
- ."bar3:= \$(patsubst %.c,%.o,x.c.c bar.c)\n"
- ."all:\n"
- ."\t\@echo \$(bar)\n"
- ."\t\@echo \$(bar2)\n"
- ."\t\@echo \$(bar3)\n";
+# Generic patsubst test: test both the function and variable form.
-# END of Contents of MAKEFILE
+run_make_test('
+foo := a.o b.o c.o
+bar := $(foo:.o=.c)
+bar2:= $(foo:%.o=%.c)
+bar3:= $(patsubst %.c,%.o,x.c.c bar.c)
+all:;@echo $(bar); echo $(bar2); echo $(bar3)',
+'',
+'a.c b.c c.c
+a.c b.c c.c
+x.c.o bar.o');
-close(MAKEFILE);
+# Patsubst without '%'--shouldn't match because the whole word has to match
+# in patsubst. Based on a bug report by Markus Mauhart <qwe123@chello.at>
-&run_make_with_options($makefile,"",&get_logfile);
+run_make_test('all:;@echo $(patsubst Foo,Repl,FooFoo)', '', 'FooFoo');
-# Create the answer to what should be produced by this Makefile
-$answer = "a.c b.c c.c\n"
- ."a.c b.c c.c\n"
- ."x.c.o bar.o\n";
+# Variable subst where a pattern matches multiple times in a single word.
+# Based on a bug report by Markus Mauhart <qwe123@chello.at>
-&compare_output($answer,&get_logfile(1));
+run_make_test('
+A := fooBARfooBARfoo
+all:;@echo $(A:fooBARfoo=REPL)', '', 'fooBARREPL');
1;