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