make(1): clean up unit testsdiff -r1.7 -r1.8 src/usr.bin/make/unit-tests/dir.mk
(rillig)
--- src/usr.bin/make/unit-tests/dir.mk 2020/10/31 21:30:03 1.7
+++ src/usr.bin/make/unit-tests/dir.mk 2020/11/03 18:42:33 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: dir.mk,v 1.7 2020/10/31 21:30:03 rillig Exp $ | 1 | # $NetBSD: dir.mk,v 1.8 2020/11/03 18:42:33 rillig Exp $ | |
2 | # | 2 | # | |
3 | # Tests for dir.c. | 3 | # Tests for dir.c. | |
4 | 4 | |||
5 | .MAKEFLAGS: -m / # hide /usr/share/mk from the debug log | 5 | .MAKEFLAGS: -m / # hide /usr/share/mk from the debug log | |
6 | 6 | |||
7 | # Dependency lines may use braces for expansion. | 7 | # Dependency lines may use braces for expansion. | |
8 | # See DirExpandCurly for the implementation. | 8 | # See DirExpandCurly for the implementation. | |
9 | all: {one,two,three} | 9 | all: {one,two,three} | |
10 | 10 | |||
11 | # XXX: The above dependency line is parsed as a single node named | 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" | 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 | 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 | 14 | # on the left-hand side of a dependency operator. However, it is listed | |
@@ -54,27 +54,28 @@ fifteen: | @@ -54,27 +54,28 @@ fifteen: | |||
54 | # There may be multiple brace groups side by side. | 54 | # There may be multiple brace groups side by side. | |
55 | all: {pre-,}{patch,configure} | 55 | all: {pre-,}{patch,configure} | |
56 | 56 | |||
57 | pre-patch patch pre-configure configure: | 57 | pre-patch patch pre-configure configure: | |
58 | : $@ | 58 | : $@ | |
59 | 59 | |||
60 | # Empty pieces are allowed in the braces. | 60 | # Empty pieces are allowed in the braces. | |
61 | all: {fetch,extract}{,-post} | 61 | all: {fetch,extract}{,-post} | |
62 | 62 | |||
63 | fetch fetch-post extract extract-post: | 63 | fetch fetch-post extract extract-post: | |
64 | : $@ | 64 | : $@ | |
65 | 65 | |||
66 | # The expansions may have duplicates. | 66 | # The expansions may have duplicates. | |
67 | # These are merged together because of the dependency line. | 67 | # When the source of the dependency line is expanded later, each of the | |
68 | # expanded words will be the same. | |||
68 | all: dup-{1,1,1,1,1,1,1} | 69 | all: dup-{1,1,1,1,1,1,1} | |
69 | 70 | |||
70 | dup-1: | 71 | dup-1: | |
71 | : $@ | 72 | : $@ | |
72 | 73 | |||
73 | # Other than in Bash, the braces are also expanded if there is no comma. | 74 | # Other than in Bash, the braces are also expanded if there is no comma. | |
74 | all: {{{{{{{{{{single-word}}}}}}}}}} | 75 | all: {{{{{{{{{{single-word}}}}}}}}}} | |
75 | 76 | |||
76 | single-word: | 77 | single-word: | |
77 | : $@ | 78 | : $@ | |
78 | 79 | |||
79 | # Demonstrate debug logging for filename expansion, especially curly braces. | 80 | # Demonstrate debug logging for filename expansion, especially curly braces. | |
80 | .MAKEFLAGS: -dd | 81 | .MAKEFLAGS: -dd |
--- src/usr.bin/make/unit-tests/Attic/modts.mk 2020/10/24 08:50:17 1.7
+++ src/usr.bin/make/unit-tests/Attic/modts.mk 2020/11/03 18:42:33 1.8
@@ -1,17 +1,16 @@ | @@ -1,17 +1,16 @@ | |||
1 | # $NetBSD: modts.mk,v 1.7 2020/10/24 08:50:17 rillig Exp $ | 1 | # $NetBSD: modts.mk,v 1.8 2020/11/03 18:42:33 rillig Exp $ | |
2 | 2 | |||
3 | LIST= one two three | 3 | LIST= one two three four five six | |
4 | LIST+= four five six | |||
5 | 4 | |||
6 | FU_mod-ts= a / b / cool | 5 | FU_mod-ts= a / b / cool | |
7 | 6 | |||
8 | AAA= a a a | 7 | AAA= a a a | |
9 | B.aaa= Baaa | 8 | B.aaa= Baaa | |
10 | 9 | |||
11 | all: mod-ts mod-ts-space | 10 | all: mod-ts mod-ts-space | |
12 | 11 | |||
13 | # Use print or printf iff they are builtin. | 12 | # Use print or printf iff they are builtin. | |
14 | # XXX note that this causes problems, when make decides | 13 | # XXX note that this causes problems, when make decides | |
15 | # there is no need to use a shell, so avoid where possible. | 14 | # there is no need to use a shell, so avoid where possible. | |
16 | .if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != "" | 15 | .if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != "" | |
17 | PRINT= print -r -- | 16 | PRINT= print -r -- |
--- src/usr.bin/make/unit-tests/modmisc.mk 2020/10/24 08:50:17 1.49
+++ src/usr.bin/make/unit-tests/modmisc.mk 2020/11/03 18:42:33 1.50
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: modmisc.mk,v 1.49 2020/10/24 08:50:17 rillig Exp $ | 1 | # $NetBSD: modmisc.mk,v 1.50 2020/11/03 18:42:33 rillig Exp $ | |
2 | # | 2 | # | |
3 | # miscellaneous modifier tests | 3 | # miscellaneous modifier tests | |
4 | 4 | |||
5 | # do not put any dirs in this list which exist on some | 5 | # do not put any dirs in this list which exist on some | |
6 | # but not all target systems - an exists() check is below. | 6 | # but not all target systems - an exists() check is below. | |
7 | path= :/bin:/tmp::/:.:/no/such/dir:. | 7 | path= :/bin:/tmp::/:.:/no/such/dir:. | |
8 | # strip cwd from path. | 8 | # strip cwd from path. | |
9 | MOD_NODOT= S/:/ /g:N.:ts: | 9 | MOD_NODOT= S/:/ /g:N.:ts: | |
10 | # and decorate, note that $'s need to be doubled. Also note that | 10 | # and decorate, note that $'s need to be doubled. Also note that | |
11 | # the modifier_variable can be used with other modifiers. | 11 | # the modifier_variable can be used with other modifiers. | |
12 | MOD_NODOTX= S/:/ /g:N.:@d@'$$d'@ | 12 | MOD_NODOTX= S/:/ /g:N.:@d@'$$d'@ | |
13 | # another mod - pretend it is more interesting | 13 | # another mod - pretend it is more interesting | |
14 | MOD_HOMES= S,/home/,/homes/, | 14 | MOD_HOMES= S,/home/,/homes/, | |
@@ -38,44 +38,44 @@ paths+= ${d:${MOD_OPT}:${MOD_HOMES}} | @@ -38,44 +38,44 @@ paths+= ${d:${MOD_OPT}:${MOD_HOMES}} | |||
38 | 38 | |||
39 | modvarloop: | 39 | modvarloop: | |
40 | @echo "path_/usr/xbin=${path_/usr/xbin}" | 40 | @echo "path_/usr/xbin=${path_/usr/xbin}" | |
41 | @echo "paths=${paths}" | 41 | @echo "paths=${paths}" | |
42 | @echo "PATHS=${paths:tu}" | 42 | @echo "PATHS=${paths:tu}" | |
43 | 43 | |||
44 | # When a modifier is applied to the "" variable, the result is discarded. | 44 | # When a modifier is applied to the "" variable, the result is discarded. | |
45 | emptyvar: | 45 | emptyvar: | |
46 | @echo S:${:S,^$,empty,} | 46 | @echo S:${:S,^$,empty,} | |
47 | @echo C:${:C,^$,empty,} | 47 | @echo C:${:C,^$,empty,} | |
48 | @echo @:${:@var@${var}@} | 48 | @echo @:${:@var@${var}@} | |
49 | 49 | |||
50 | # The :U modifier turns even the "" variable into something that has a value. | 50 | # The :U modifier turns even the "" variable into something that has a value. | |
51 | # The resulting variable is empty, but is still considered to contain a | 51 | # The value of the resulting expression is empty, but is still considered to | |
52 | # single empty word. This word can be accessed by the :S and :C modifiers, | 52 | # contain a single empty word. This word can be accessed by the :S and :C | |
53 | # but not by the :@ modifier since it explicitly skips empty words. | 53 | # modifiers, but not by the :@ modifier since it explicitly skips empty words. | |
54 | undefvar: | 54 | undefvar: | |
55 | @echo S:${:U:S,^$,empty,} | 55 | @echo S:${:U:S,^$,empty,} | |
56 | @echo C:${:U:C,^$,empty,} | 56 | @echo C:${:U:C,^$,empty,} | |
57 | @echo @:${:U:@var@empty@} | 57 | @echo @:${:U:@var@empty@} | |
58 | 58 | |||
59 | 59 | |||
60 | mod-quote: | 60 | mod-quote: | |
61 | @echo $@: new${.newline:Q}${.newline:Q}line | 61 | @echo $@: new${.newline:Q}${.newline:Q}line | |
62 | 62 | |||
63 | # Cover the bmake_realloc in brk_string. | 63 | # Cover the bmake_realloc in brk_string. | |
64 | mod-break-many-words: | 64 | mod-break-many-words: | |
65 | @echo $@: ${UNDEF:U:range=500:[#]} | 65 | @echo $@: ${UNDEF:U:range=500:[#]} | |
66 | 66 | |||
67 | # To apply a modifier indirectly via another variable, the whole | 67 | # To apply a modifier indirectly via another variable, the whole | |
68 | # modifier must be put into a single variable. | 68 | # modifier must be put into a single variable expression. | |
69 | .if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}" | 69 | .if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}" | |
70 | . warning unexpected | 70 | . warning unexpected | |
71 | .endif | 71 | .endif | |
72 | 72 | |||
73 | # Adding another level of indirection (the 2 nested :U expressions) helps. | 73 | # Adding another level of indirection (the 2 nested :U expressions) helps. | |
74 | .if ${value:L:${:U${:US}${:U,value,replacement,}}} != "replacement" | 74 | .if ${value:L:${:U${:US}${:U,value,replacement,}}} != "replacement" | |
75 | . warning unexpected | 75 | . warning unexpected | |
76 | .endif | 76 | .endif | |
77 | 77 | |||
78 | # Multiple indirect modifiers can be applied one after another as long as | 78 | # Multiple indirect modifiers can be applied one after another as long as | |
79 | # they are separated with colons. | 79 | # they are separated with colons. | |
80 | .if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE" | 80 | .if ${value:L:${:US,a,A,}:${:US,e,E,}} != "vAluE" | |
81 | . warning unexpected | 81 | . warning unexpected |
--- src/usr.bin/make/unit-tests/varmod-exclam-shell.mk 2020/10/24 08:46:08 1.3
+++ src/usr.bin/make/unit-tests/varmod-exclam-shell.mk 2020/11/03 18:42:33 1.4
@@ -1,28 +1,37 @@ | @@ -1,28 +1,37 @@ | |||
1 | # $NetBSD: varmod-exclam-shell.mk,v 1.3 2020/10/24 08:46:08 rillig Exp $ | 1 | # $NetBSD: varmod-exclam-shell.mk,v 1.4 2020/11/03 18:42:33 rillig Exp $ | |
2 | # | 2 | # | |
3 | # Tests for the :!cmd! variable modifier. | 3 | # Tests for the :!cmd! variable modifier, which evaluates the modifier | |
4 | # argument, independent of the value or the name of the original variable. | |||
4 | 5 | |||
5 | .if ${:!echo hello | tr 'l' 'l'!} != "hello" | 6 | .if ${:!echo hello | tr 'l' 'l'!} != "hello" | |
6 | . warning unexpected | 7 | . error | |
7 | .endif | 8 | .endif | |
8 | 9 | |||
9 | # The output is truncated at the first null byte. | 10 | # The output is truncated at the first null byte. | |
10 | # Cmd_Exec returns only a string pointer without length information. | 11 | # Cmd_Exec returns only a string pointer without length information. | |
12 | # Truncating the output is not necessarily intended but may also be a side | |||
13 | # effect from the implementation. Having null bytes in the output of a | |||
14 | # shell command is so unusual that it doesn't matter in practice. | |||
11 | .if ${:!echo hello | tr 'l' '\0'!} != "he" | 15 | .if ${:!echo hello | tr 'l' '\0'!} != "he" | |
12 | . warning unexpected | 16 | . error | |
13 | .endif | 17 | .endif | |
14 | 18 | |||
19 | # The newline at the end of the output is stripped. | |||
15 | .if ${:!echo!} != "" | 20 | .if ${:!echo!} != "" | |
16 | . warning A newline at the end of the output must be stripped. | 21 | . error | |
17 | .endif | 22 | .endif | |
18 | 23 | |||
24 | # Only the final newline of the output is stripped. All other newlines are | |||
25 | # converted to spaces. | |||
19 | .if ${:!echo;echo!} != " " | 26 | .if ${:!echo;echo!} != " " | |
20 | . warning Only a single newline at the end of the output is stripped. | 27 | . error | |
21 | .endif | 28 | .endif | |
22 | 29 | |||
30 | # Each newline in the output is converted to a space, except for the newline | |||
31 | # at the end of the output, which is stripped. | |||
23 | .if ${:!echo;echo;echo;echo!} != " " | 32 | .if ${:!echo;echo;echo;echo!} != " " | |
24 | . warning Other newlines in the output are converted to spaces. | 33 | . error | |
25 | .endif | 34 | .endif | |
26 | 35 | |||
27 | all: | 36 | all: | |
28 | @:; | 37 | @:; |