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