]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/dir.mk
Update to bmake-20201101
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / dir.mk
1 # $NetBSD: dir.mk,v 1.7 2020/10/31 21:30:03 rillig Exp $
2 #
3 # Tests for dir.c.
4
5 .MAKEFLAGS: -m /                # hide /usr/share/mk from the debug log
6
7 # Dependency lines may use braces for expansion.
8 # See DirExpandCurly for the implementation.
9 all: {one,two,three}
10
11 # XXX: The above dependency line is parsed as a single node named
12 # "{one,two,three}".  There are no individual targets "one", "two", "three"
13 # yet.  The node exists but is not a target since it never appeared
14 # on the left-hand side of a dependency operator.  However, it is listed
15 # in .ALLTARGETS (which lists all nodes, not only targets).
16 .if target(one)
17 .  error
18 .endif
19 .if target({one,two,three})
20 .  error
21 .endif
22 .if ${.ALLTARGETS:M{one,two,three}} != "{one,two,three}"
23 .  error
24 .endif
25
26 one:
27         : 1
28 two:
29         : 2
30 three:
31         : 3
32
33 # The braces may start in the middle of a word.
34 all: f{our,ive}
35
36 four:
37         : 4
38 five:
39         : 5
40 six:
41         : 6
42
43 # Nested braces work as expected since 2020-07-31 19:06 UTC.
44 # They had been broken at least since 2003-01-01, probably even longer.
45 all: {{thi,fou}r,fif}teen
46
47 thirteen:
48         : 13
49 fourteen:
50         : 14
51 fifteen:
52         : 15
53
54 # There may be multiple brace groups side by side.
55 all: {pre-,}{patch,configure}
56
57 pre-patch patch pre-configure configure:
58         : $@
59
60 # Empty pieces are allowed in the braces.
61 all: {fetch,extract}{,-post}
62
63 fetch fetch-post extract extract-post:
64         : $@
65
66 # The expansions may have duplicates.
67 # These are merged together because of the dependency line.
68 all: dup-{1,1,1,1,1,1,1}
69
70 dup-1:
71         : $@
72
73 # Other than in Bash, the braces are also expanded if there is no comma.
74 all: {{{{{{{{{{single-word}}}}}}}}}}
75
76 single-word:
77         : $@
78
79 # Demonstrate debug logging for filename expansion, especially curly braces.
80 .MAKEFLAGS: -dd
81 # The below line does not call Dir_Expand yet.
82 # It is expanded only when necessary, that is, when the 'debug' target is
83 # indeed made.
84 debug: {{thi,fou}r,fif}twen
85 # Therefore, keep the debug logging active.
86
87 .PHONY: one two three four five six
88 .PHONY: thirteen fourteen fifteen
89 .PHONY: single-word
90 .PHONY: pre-patch patch pre-configure configure
91 .PHONY: fetch fetch-post extract extract-post
92 .PHONY: dup-1 single-word
93 .PHONY: all