diff options
Diffstat (limited to 'unit-tests/varname-dot-curdir.mk')
-rw-r--r-- | unit-tests/varname-dot-curdir.mk | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/unit-tests/varname-dot-curdir.mk b/unit-tests/varname-dot-curdir.mk index 3795d87b030fd..e7af5c9528444 100644 --- a/unit-tests/varname-dot-curdir.mk +++ b/unit-tests/varname-dot-curdir.mk @@ -1,8 +1,45 @@ -# $NetBSD: varname-dot-curdir.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $ +# $NetBSD: varname-dot-curdir.mk,v 1.7 2020/10/08 19:09:08 rillig Exp $ # -# Tests for the special .CURDIR variable. +# Tests for the special .CURDIR variable, which is initially set to the +# canonical path of the current working directory, when make started. -# TODO: Implementation +# In all normal situations, the current directory exists, and its name can +# be resolved. If not, make fails at startup. +# +# It would be possible on some systems to remove the current directory, even +# while a process runs in it, but this is so unrealistic that it's no worth +# testing. +.if !exists(${.CURDIR}) +. error +.endif +.if !exists(${.CURDIR}/) +. error +.endif +.if !exists(${.CURDIR}/.) +. error +.endif +.if !exists(${.CURDIR}/..) +. error +.endif + +# Until 2020-10-04, assigning the result of a shell assignment to .CURDIR +# tried to add the shell command ("echo /") to the .PATH instead of the +# output of the shell command ("/"). Since "echo /" does not exist, the +# .PATH was left unmodified. See VarAssign_Eval. +# +# Since 2020-10-04, the output of the shell command is added to .PATH. +.CURDIR!= echo / +.if ${.PATH:M/} != "/" +. error +.endif + +# A normal assignment works fine, as does a substitution assignment. +# Appending to .CURDIR does not make sense, therefore it doesn't matter that +# this code path is buggy as well. +.CURDIR= / +.if ${.PATH:M/} != "/" +. error +.endif all: @:; |