Home | History | Annotate | Line # | Download | only in unit-tests
      1 # $NetBSD: varname-dot-curdir.mk,v 1.7 2020/10/08 19:09:08 rillig Exp $
      2 #
      3 # Tests for the special .CURDIR variable, which is initially set to the
      4 # canonical path of the current working directory, when make started.
      5 
      6 # In all normal situations, the current directory exists, and its name can
      7 # be resolved.  If not, make fails at startup.
      8 #
      9 # It would be possible on some systems to remove the current directory, even
     10 # while a process runs in it, but this is so unrealistic that it's no worth
     11 # testing.
     12 .if !exists(${.CURDIR})
     13 .  error
     14 .endif
     15 .if !exists(${.CURDIR}/)
     16 .  error
     17 .endif
     18 .if !exists(${.CURDIR}/.)
     19 .  error
     20 .endif
     21 .if !exists(${.CURDIR}/..)
     22 .  error
     23 .endif
     24 
     25 # Until 2020-10-04, assigning the result of a shell assignment to .CURDIR
     26 # tried to add the shell command ("echo /") to the .PATH instead of the
     27 # output of the shell command ("/").  Since "echo /" does not exist, the
     28 # .PATH was left unmodified.  See VarAssign_Eval.
     29 #
     30 # Since 2020-10-04, the output of the shell command is added to .PATH.
     31 .CURDIR!=	echo /
     32 .if ${.PATH:M/} != "/"
     33 .  error
     34 .endif
     35 
     36 # A normal assignment works fine, as does a substitution assignment.
     37 # Appending to .CURDIR does not make sense, therefore it doesn't matter that
     38 # this code path is buggy as well.
     39 .CURDIR=	/
     40 .if ${.PATH:M/} != "/"
     41 .  error
     42 .endif
     43 
     44 all:
     45 	@:;
     46