diff options
Diffstat (limited to 'tests/scripts/features/targetvars')
-rw-r--r-- | tests/scripts/features/targetvars | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/tests/scripts/features/targetvars b/tests/scripts/features/targetvars new file mode 100644 index 0000000..e9fe092 --- /dev/null +++ b/tests/scripts/features/targetvars @@ -0,0 +1,108 @@ +# -*-perl-*- +$description = "Test target-specific variable settings."; + +$details = "\ +Create a makefile containing various flavors of target-specific variable +values, override and non-override, and using various variable expansion +rules, semicolon interference, etc."; + +open(MAKEFILE,"> $makefile"); + +print MAKEFILE <<'EOF'; +SHELL = /bin/sh +export FOO = foo +export BAR = bar +one: override FOO = one +one two: ; @echo $(FOO) $(BAR) +two: BAR = two +three: ; BAR=1000 + @echo $(FOO) $(BAR) +# Some things that shouldn't be target vars +funk : override +funk : override adelic +adelic override : ; echo $@ +# Test per-target recursive variables +four:FOO=x +four:VAR$(FOO)=ok +four: ; @echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)' +five:FOO=x +five six : VAR$(FOO)=good +five six: ;@echo '$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)' +# Test per-target variable inheritance +seven: eight +seven eight: ; @echo $@: $(FOO) $(BAR) +seven: BAR = seven +seven: FOO = seven +eight: BAR = eight +# Test the export keyword with per-target variables +nine: ; @echo $(FOO) $(BAR) $$FOO $$BAR +nine: FOO = wallace +# Test = escaping +EQ = = +ten: one\=two +ten: one \= two +ten one$(EQ)two $(EQ):;@echo $@ +.PHONY: one two three four five six seven eight nine ten $(EQ) one$(EQ)two +# Test target-specific vars with pattern/suffix rules +QVAR = qvar +RVAR = = +%.q : ; @echo $(QVAR) $(RVAR) +foo.q : RVAR += rvar +# Target-specific vars with multiple LHS pattern rules +%.r %.s %.t: ; @echo $(QVAR) $(RVAR) $(SVAR) $(TVAR) +foo.r : RVAR += rvar +foo.t : TVAR := $(QVAR) +EOF + +close(MAKEFILE); + +# TEST #1 + +&run_make_with_options($makefile, "one two three", &get_logfile); +$answer = "one bar\nfoo two\nBAR=1000\nfoo bar\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #2 + +&run_make_with_options($makefile, "one two FOO=1 BAR=2", &get_logfile); +$answer = "one 2\n1 2\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #3 + +&run_make_with_options($makefile, "four", &get_logfile); +$answer = "x ok ok\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #4 + +&run_make_with_options($makefile, "seven", &get_logfile); +$answer = "eight: seven eight\nseven: seven seven\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #5 + +&run_make_with_options($makefile, "nine", &get_logfile); +$answer = "wallace bar wallace bar\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #6 + +&run_make_with_options($makefile, "ten", &get_logfile); +$answer = "one=two\none bar\n=\nfoo two\nten\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #6 + +&run_make_with_options($makefile, "foo.q bar.q", &get_logfile); +$answer = "qvar = rvar\nqvar =\n"; +&compare_output($answer,&get_logfile(1)); + +# TEST #7 + +&run_make_with_options($makefile, "foo.t bar.s", &get_logfile); +$answer = "qvar = qvar\nqvar =\n"; +&compare_output($answer,&get_logfile(1)); + + +1; |