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