xref: /freebsd/contrib/bmake/unit-tests/varname-dot-path.mk (revision 956e45f6fb3e18b8e89b1341708db60c30bb9f27)
1*956e45f6SSimon J. Gerraty# $NetBSD: varname-dot-path.mk,v 1.3 2020/10/02 18:46:54 rillig Exp $
22c3632d1SSimon J. Gerraty#
3*956e45f6SSimon J. Gerraty# Tests for the special .PATH variable, which TODO: describe the purpose.
42c3632d1SSimon J. Gerraty
5*956e45f6SSimon J. Gerraty_!=	mkdir -p varname-dot-path.d
6*956e45f6SSimon J. Gerraty
7*956e45f6SSimon J. Gerraty# By default, .PATH consists of "." and .CURDIR.
8*956e45f6SSimon J. Gerraty# XXX: Why both? Shouldn't they have the same effect?
9*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR}"
10*956e45f6SSimon J. Gerraty.  error ${.PATH}
11*956e45f6SSimon J. Gerraty.endif
12*956e45f6SSimon J. Gerraty
13*956e45f6SSimon J. Gerraty# The special target .PATH adds a directory to the path.
14*956e45f6SSimon J. Gerraty.PATH: /
15*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR} /"
16*956e45f6SSimon J. Gerraty.  error ${.PATH}
17*956e45f6SSimon J. Gerraty.endif
18*956e45f6SSimon J. Gerraty
19*956e45f6SSimon J. Gerraty# Only existing directories are added to the path, the others are ignored.
20*956e45f6SSimon J. Gerraty.PATH: /nonexistent
21*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR} /"
22*956e45f6SSimon J. Gerraty.  error ${.PATH}
23*956e45f6SSimon J. Gerraty.endif
24*956e45f6SSimon J. Gerraty
25*956e45f6SSimon J. Gerraty# Only directories are added to the path, not regular files.
26*956e45f6SSimon J. Gerraty.PATH: ${.PARSEDIR}/${.PARSEFILE}
27*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR} /"
28*956e45f6SSimon J. Gerraty.  error ${.PATH}
29*956e45f6SSimon J. Gerraty.endif
30*956e45f6SSimon J. Gerraty
31*956e45f6SSimon J. Gerraty# Relative directories can be added as well.
32*956e45f6SSimon J. Gerraty# Each directory is only added once to the path.
33*956e45f6SSimon J. Gerraty.PATH: varname-dot-path.d /
34*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR} / varname-dot-path.d"
35*956e45f6SSimon J. Gerraty.  error ${.PATH}
36*956e45f6SSimon J. Gerraty.endif
37*956e45f6SSimon J. Gerraty
38*956e45f6SSimon J. Gerraty# The pathnames are not normalized before being added to the path.
39*956e45f6SSimon J. Gerraty.PATH: ./.
40*956e45f6SSimon J. Gerraty.if ${.PATH} != ". ${.CURDIR} / varname-dot-path.d ./."
41*956e45f6SSimon J. Gerraty.  error ${.PATH}
42*956e45f6SSimon J. Gerraty.endif
43*956e45f6SSimon J. Gerraty
44*956e45f6SSimon J. Gerraty# The two default entries can be placed at the back of the path,
45*956e45f6SSimon J. Gerraty# by adding the special entry ".DOTLAST" somewhere in the path.
46*956e45f6SSimon J. Gerraty# The entry .DOTLAST, if any, is listed in the path, always at the
47*956e45f6SSimon J. Gerraty# very beginning, to make this magic less surprising.
48*956e45f6SSimon J. Gerraty.PATH: .DOTLAST
49*956e45f6SSimon J. Gerraty.if ${.PATH} != ".DOTLAST / varname-dot-path.d ./. . ${.CURDIR}"
50*956e45f6SSimon J. Gerraty.  error ${.PATH}
51*956e45f6SSimon J. Gerraty.endif
52*956e45f6SSimon J. Gerraty
53*956e45f6SSimon J. Gerraty_!=	rmdir varname-dot-path.d
542c3632d1SSimon J. Gerraty
552c3632d1SSimon J. Gerratyall:
562c3632d1SSimon J. Gerraty	@:;
57