Add a regression test for the passing of command line

variable assignments via the MAKEFLAGS environment variable.
This commit is contained in:
Hartmut Brandt 2004-08-04 07:40:58 +00:00
parent caf55ed6b5
commit 48ec21e7e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133109
2 changed files with 174 additions and 0 deletions

View File

@ -53,6 +53,9 @@ all:
@echo "Running test double_quotes2"
@! ${MAKE} double_quotes2 >/dev/null 2>&1 && true || ${MAKE} failure
@echo "PASS: Test double_quotes2 detected no regression."
@echo "Running test pass_cmd_vars "
@${MAKE} pass_cmd_vars || ${MAKE} failure
@echo "PASS: Test pass_cmd_vars detected no regression."
.if make(double)
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
@ -132,6 +135,90 @@ double_quotes2:
@cat /dev/null ""
.endif
#
# Check passing of variable via MAKEFLAGS
#
.if make(pass_cmd_vars)
pass_cmd_vars:
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
.endif
.if make(pass_cmd_vars_1)
# Check that the variable definition arrived from the calling make
pass_cmd_vars_1:
@:
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
.error "variables not passed through MAKEFLAGS"
.endif
# Check that the variable definition is in MAKEFLAGS
.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2"
.error "variable assignment not found in $${MAKEFLAGS}"
.endif
# Check that the variable definition is not in MFLAGS
.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != ""
.error "variable assignment found in $${MFLAGS}"
.endif
.endif
.if make(pass_cmd_vars_2)
# Check that we cannot override the passed variables
CMD1=foo1
CMD2=foo2
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables overridden"
.endif
pass_cmd_vars_2:
@:
.endif
.if make(pass_cmd_vars_3)
# Check that we can override the passed variables on the next sub-make's
# command line
pass_cmd_vars_3:
@${MAKE} CMD1=foo1 pass_cmd_vars_3_1
.endif
.if make(pass_cmd_vars_3_1)
.if ${CMD1} != foo1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden on command line"
.endif
pass_cmd_vars_3_1:
@:
.endif
.if make(pass_cmd_vars_4)
# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
# by evaluating the .MAKEFLAGS target.
.MAKEFLAGS: CMD1=baz1
pass_cmd_vars_4:
@:
# The following does not yet work (see standards/57295)
# ${MAKE} pass_cmd_vars_4_1
.if ${CMD1} != baz1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target"
.endif
.endif
.if make(pass_cmd_vars_4_1)
.if ${CMD1} != baz1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)"
.endif
pass_cmd_vars_4_1:
@:
.endif
failure:
@echo "FAIL: Test failed: regression detected. See above."
@false

View File

@ -53,6 +53,9 @@ all:
@echo "Running test double_quotes2"
@! ${MAKE} double_quotes2 >/dev/null 2>&1 && true || ${MAKE} failure
@echo "PASS: Test double_quotes2 detected no regression."
@echo "Running test pass_cmd_vars "
@${MAKE} pass_cmd_vars || ${MAKE} failure
@echo "PASS: Test pass_cmd_vars detected no regression."
.if make(double)
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
@ -132,6 +135,90 @@ double_quotes2:
@cat /dev/null ""
.endif
#
# Check passing of variable via MAKEFLAGS
#
.if make(pass_cmd_vars)
pass_cmd_vars:
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
@${MAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
.endif
.if make(pass_cmd_vars_1)
# Check that the variable definition arrived from the calling make
pass_cmd_vars_1:
@:
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
.error "variables not passed through MAKEFLAGS"
.endif
# Check that the variable definition is in MAKEFLAGS
.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2"
.error "variable assignment not found in $${MAKEFLAGS}"
.endif
# Check that the variable definition is not in MFLAGS
.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != ""
.error "variable assignment found in $${MFLAGS}"
.endif
.endif
.if make(pass_cmd_vars_2)
# Check that we cannot override the passed variables
CMD1=foo1
CMD2=foo2
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables overridden"
.endif
pass_cmd_vars_2:
@:
.endif
.if make(pass_cmd_vars_3)
# Check that we can override the passed variables on the next sub-make's
# command line
pass_cmd_vars_3:
@${MAKE} CMD1=foo1 pass_cmd_vars_3_1
.endif
.if make(pass_cmd_vars_3_1)
.if ${CMD1} != foo1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden on command line"
.endif
pass_cmd_vars_3_1:
@:
.endif
.if make(pass_cmd_vars_4)
# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
# by evaluating the .MAKEFLAGS target.
.MAKEFLAGS: CMD1=baz1
pass_cmd_vars_4:
@:
# The following does not yet work (see standards/57295)
# ${MAKE} pass_cmd_vars_4_1
.if ${CMD1} != baz1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target"
.endif
.endif
.if make(pass_cmd_vars_4_1)
.if ${CMD1} != baz1 || ${CMD2} != cmd2
.error "MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)"
.endif
pass_cmd_vars_4_1:
@:
.endif
failure:
@echo "FAIL: Test failed: regression detected. See above."
@false