diff options
Diffstat (limited to 'unit-tests/opt-env.mk')
-rw-r--r-- | unit-tests/opt-env.mk | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/unit-tests/opt-env.mk b/unit-tests/opt-env.mk index 32e95ef41f5a..0cfa1aa6470f 100644 --- a/unit-tests/opt-env.mk +++ b/unit-tests/opt-env.mk @@ -1,8 +1,45 @@ -# $NetBSD: opt-env.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: opt-env.mk,v 1.3 2022/01/23 16:09:38 rillig Exp $ # # Tests for the -e command line option. -# TODO: Implementation +# The variable FROM_ENV is defined in ./Makefile. -all: - @:; +.MAKEFLAGS: -e + +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +# Try to override the variable; this does not have any effect. +FROM_ENV= value-from-mk +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +# Try to append to the variable; this also doesn't have any effect. +FROM_ENV+= appended +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +# The default assignment also cannot change the variable. +FROM_ENV?= default +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +# Neither can the assignment modifiers. +.if ${FROM_ENV::=from-condition} +.endif +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +# Even .undef doesn't work since it only affects the global scope, +# which is independent from the environment variables. +.undef FROM_ENV +.if ${FROM_ENV} != value-from-env +. error ${FROM_ENV} +.endif + +all: .PHONY |