From 310a4a288df50ff92edfc5fd8c22c4de0745cc75 Mon Sep 17 00:00:00 2001 From: harti Date: Wed, 4 Aug 2004 07:40:58 +0000 Subject: Add a regression test for the passing of command line variable assignments via the MAKEFLAGS environment variable. --- tools/build/make_check/Makefile | 87 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) (limited to 'tools/build') diff --git a/tools/build/make_check/Makefile b/tools/build/make_check/Makefile index fcee42e..348e9dd 100644 --- a/tools/build/make_check/Makefile +++ b/tools/build/make_check/Makefile @@ -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 -- cgit v1.1