CVS commit: src/usr.bin/make/unit-tests

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 15:05:15 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-keep-going-indirect.mk

Log Message:
tests/make: pass PATH onto child processes

This fixes the tests on some Cygwin variant where the shell does not
initialize the PATH environment variable when it's missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk
diff -u src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.2 src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.3
--- src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.2	Sat Feb 12 20:05:36 2022
+++ src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk	Tue Apr  2 15:05:15 2024
@@ -1,4 +1,4 @@
-# $NetBSD: opt-keep-going-indirect.mk,v 1.2 2022/02/12 20:05:36 rillig Exp $
+# $NetBSD: opt-keep-going-indirect.mk,v 1.3 2024/04/02 15:05:15 rillig Exp $
 #
 # Tests for the -k command line option, which stops building a target as soon
 # as an error is detected, but continues building the other, independent
@@ -49,19 +49,19 @@
 # to the child processes.
 all:
 	@echo 'direct compat'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k direct; echo "exited $$?"
 	@echo
 
 	@echo 'direct jobs'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct -j1; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k direct -j1; echo "exited $$?"
 	@echo
 
 	@echo 'indirect compat'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k indirect; echo "exited $$?"
 	@echo
 
 	@echo 'indirect jobs'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect -j1; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k indirect -j1; echo "exited $$?"
 	@echo
 
 indirect: direct



CVS commit: src/usr.bin/make/unit-tests

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 15:05:15 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-keep-going-indirect.mk

Log Message:
tests/make: pass PATH onto child processes

This fixes the tests on some Cygwin variant where the shell does not
initialize the PATH environment variable when it's missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 11:11:00 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-chdir.exp opt-chdir.mk

Log Message:
tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-chdir.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-chdir.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/opt-chdir.exp
diff -u src/usr.bin/make/unit-tests/opt-chdir.exp:1.3 src/usr.bin/make/unit-tests/opt-chdir.exp:1.4
--- src/usr.bin/make/unit-tests/opt-chdir.exp:1.3	Sun Dec 27 11:47:04 2020
+++ src/usr.bin/make/unit-tests/opt-chdir.exp	Tue Apr  2 11:11:00 2024
@@ -1,5 +1,3 @@
-make: chdir /././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././
 ././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././.
 /././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././
 

CVS commit: src/usr.bin/make/unit-tests

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 11:11:00 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-chdir.exp opt-chdir.mk

Log Message:
tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-chdir.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-chdir.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 src/usr.bin/make/unit-tests/var-scope-local.exp:1.9
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.8	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Tue Mar  5 23:07:58 2024
@@ -60,19 +60,12 @@ dir/subdir/inference-rule-chain.ir-to: *
 : Making var-scope-local.c out of nothing.
 : Making var-scope-local.o from var-scope-local.c.
 : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
-: Making var-scope-local-assign.o with VAR="local".
-var-scope-local-assign.o env has VAR='local'
-: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
-var-scope-local-append.o env has VAR='local to var-scope-local-append.o'
-: Making var-scope-local-append-global.o with VAR="global+local".
-var-scope-local-append-global.o env has VAR='global+local'
-: Making var-scope-local-default.o with VAR="global".
-var-scope-local-default.o env has VAR='global'
-: Making var-scope-local-subst.o with VAR="global+local".
-var-scope-local-subst.o env has VAR='global+local'
-: Making var-scope-local-shell.o with VAR="output".
-var-scope-local-shell.o env has VAR='output'
-: var-scope-local-use.o uses .USE VAR="global"
-var-scope-local-use.o env has VAR='global'
+Making var-scope-local-assign.o with make 'local' and env 'local'.
+Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
+Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-default.o with make 'global' and env 'global'.
+Making var-scope-local-subst.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-shell.o with make 'output' and env 'output'.
+Making .USE var-scope-local-use.o with make 'global' and env 'global'.
 : all overwritten
 exit status 0

Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 src/usr.bin/make/unit-tests/var-scope-local.mk:1.11
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.10	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Tue Mar  5 23:07:58 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $
+# $NetBSD: var-scope-local.mk,v 1.11 2024/03/05 23:07:58 rillig Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.  These variables
 # are relatively short-lived as they are created just before making the
@@ -199,8 +199,7 @@ var-scope-local-append-global.o \
 var-scope-local-default.o \
 var-scope-local-subst.o \
 var-scope-local-shell.o:
-	: Making ${.TARGET} with VAR="${VAR}".
-	@echo "${.TARGET} env has VAR='$$VAR'"
+	@echo "Making ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'."
 
 # Target-local variables are enabled by default.  Force them to be enabled
 # just in case a test above has disabled them.
@@ -215,7 +214,7 @@ VAR=	global
 # irrelevant.
 #
 # expect-reset
-# expect: : Making var-scope-local-assign.o with VAR="local".
+# expect: Making var-scope-local-assign.o with make 'local' and env 'local'.
 var-scope-local-assign.o: VAR= local
 
 # Assignments using '+=' do *not* look up the global value, instead they only
@@ -225,7 +224,7 @@ var-scope-local-append.o: VAR+= local
 # behaves as expected.  Note that the expression '${.TARGET}' is not resolved
 # when parsing the dependency line, its evaluation is deferred until the
 # target is actually made.
-# expect: : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+# expect: Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
 var-scope-local-append.o: VAR += to ${.TARGET}
 # To access the value of a global variable, use an expression.  This
 # expression is expanded before parsing the whole dependency line.  Since the
@@ -235,7 +234,7 @@ var-scope-local-append.o: VAR += to ${.T
 # not influence the parsing of the variable assignment.  The effective
 # variable assignment, after expanding the whole line first, is thus
 # 'VAR= global+local'.
-# expect: : Making 

CVS commit: src/usr.bin/make/unit-tests

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 20:15:59 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
make: update var-scope-local test

Show what VAR value is in environment of target script.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.7 src/usr.bin/make/unit-tests/var-scope-local.exp:1.8
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.7	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Fri Mar  1 20:15:59 2024
@@ -61,11 +61,18 @@ dir/subdir/inference-rule-chain.ir-to: *
 : Making var-scope-local.o from var-scope-local.c.
 : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
 : Making var-scope-local-assign.o with VAR="local".
+var-scope-local-assign.o env has VAR='local'
 : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+var-scope-local-append.o env has VAR='local to var-scope-local-append.o'
 : Making var-scope-local-append-global.o with VAR="global+local".
+var-scope-local-append-global.o env has VAR='global+local'
 : Making var-scope-local-default.o with VAR="global".
+var-scope-local-default.o env has VAR='global'
 : Making var-scope-local-subst.o with VAR="global+local".
+var-scope-local-subst.o env has VAR='global+local'
 : Making var-scope-local-shell.o with VAR="output".
+var-scope-local-shell.o env has VAR='output'
 : var-scope-local-use.o uses .USE VAR="global"
+var-scope-local-use.o env has VAR='global'
 : all overwritten
 exit status 0

Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.9 src/usr.bin/make/unit-tests/var-scope-local.mk:1.10
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.9	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Fri Mar  1 20:15:59 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.9 2023/12/20 09:03:09 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.  These variables
 # are relatively short-lived as they are created just before making the
@@ -200,12 +200,14 @@ var-scope-local-default.o \
 var-scope-local-subst.o \
 var-scope-local-shell.o:
 	: Making ${.TARGET} with VAR="${VAR}".
+	@echo "${.TARGET} env has VAR='$$VAR'"
 
 # Target-local variables are enabled by default.  Force them to be enabled
 # just in case a test above has disabled them.
 .MAKE.TARGET_LOCAL_VARIABLES= yes
 
 VAR=	global
+.export VAR
 
 # If the sources of a dependency line look like a variable assignment, make
 # treats them as such.  There is only a single variable assignment per
@@ -264,6 +266,7 @@ var-scope-local-shell.o: VAR != echo out
 # expect: : var-scope-local-use.o uses .USE VAR="global"
 a_use: .USE VAR=use
 	: ${.TARGET} uses .USE VAR="${VAR}"
+	@echo "${.TARGET} env has VAR='$$VAR'"
 
 all: var-scope-local-use.o
 var-scope-local-use.o: a_use



CVS commit: src/usr.bin/make/unit-tests

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 20:15:59 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk

Log Message:
make: update var-scope-local test

Show what VAR value is in environment of target script.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:29:50 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
tests/make: extend test for wrong evaluation in parse-only mode


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.25
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24	Sun Feb  4 08:51:57 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 09:29:50 2024
@@ -38,8 +38,10 @@ Parsing line 197: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
-make: "varmod-indirect.mk" line 274: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 274: Malformed conditional (0 && ${VAR:${M_invalid}})
+make: "varmod-indirect.mk" line 275: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 275: Malformed conditional (0 && ${VAR:${M_invalid}})
+make: "varmod-indirect.mk" line 287: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 287: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.16
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15	Sun Feb  4 08:51:57 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 09:29:50 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.15 2024/02/04 08:51:57 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.16 2024/02/04 09:29:50 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -258,8 +258,9 @@ _:=	before ${UNDEF:${:UZ}} after
 
 # In parse-only mode, the indirect modifiers must not be evaluated.
 #
-# Before var.c 1.1096 from 2024-02-04, the expression for an indirect modifier
-# was evaluated.
+# Before var.c 1.1097 from 2024-02-04, the expression for an indirect modifier
+# was partially evaluated (only the variable value, without applying any
+# modifiers) and then interpreted as modifiers to the main expression.
 #
 # The expression ${:UZ} starts with the value "", and in parse-only mode, the
 # modifier ':UZ' does not modify the expression value.  This results in an
@@ -273,3 +274,15 @@ M_invalid=	Z
 # expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
 .if 0 && ${VAR:${M_invalid}}
 .endif
+# The expression ${M_invalid} starts with the value "Z", and if its modifiers
+# were evaluated, would result in "N*Z", which is a valid modifier.  The
+# modifiers were not applied though, keeping the invalid value "Z".
+# FIXME: As of var.c 1.1096, the modifier ':S' _is_ actually evaluated.
+.if 0 && ${VAR:${M_invalid:S,^,N*,:ts:}}
+.endif
+# The ':@' modifier does not change the expression value in parse-only mode,
+# keeping the "Z".
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
+.if 0 && ${VAR:${M_invalid:@m@N*$m@:ts:}}
+.endif



CVS commit: src/usr.bin/make/unit-tests

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:29:50 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
tests/make: extend test for wrong evaluation in parse-only mode


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 08:51:57 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 08:51:57 2024
@@ -38,6 +38,8 @@ Parsing line 197: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
+make: "varmod-indirect.mk" line 274: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 274: Malformed conditional (0 && ${VAR:${M_invalid}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14	Sun Nov 19 22:32:44 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 08:51:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.14 2023/11/19 22:32:44 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.15 2024/02/04 08:51:57 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -255,4 +255,21 @@ _:=	before ${UNDEF:${:UZ}} after
 .  error
 .endif
 
-all:
+
+# In parse-only mode, the indirect modifiers must not be evaluated.
+#
+# Before var.c 1.1096 from 2024-02-04, the expression for an indirect modifier
+# was evaluated.
+#
+# The expression ${:UZ} starts with the value "", and in parse-only mode, the
+# modifier ':UZ' does not modify the expression value.  This results in an
+# empty string for the indirect modifiers, generating no warning.
+.if 0 && ${VAR:${:UZ}}
+.endif
+# The expression ${M_invalid} starts with the value "Z", which is an unknown
+# modifier.  Trying to apply this unknown modifier generated a warning.
+M_invalid=	Z
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
+.if 0 && ${VAR:${M_invalid}}
+.endif



CVS commit: src/usr.bin/make/unit-tests

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 08:51:57 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk

Log Message:
tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-indirect.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk

Log Message:
tests/make: test the '::=' modifier in target scope


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-assign.exp \
src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.18 src/usr.bin/make/unit-tests/varmod-assign.exp:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.18	Fri Dec 29 15:47:03 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Sun Jan  7 11:42:22 2024
@@ -50,4 +50,11 @@ make: Unfinished modifier for "ASSIGN" (
 ok=word
 make: " echo word; false " returned non-zero status
 err=previous
+Command: TARGET_CMD_VAR = cmd-value
+Global: TARGET_GLOBAL_VAR = global-value
+target: TARGET_TARGET_VAR = target-value
+target: TARGET_TARGET_VAR = new-value
+Global: TARGET_GLOBAL_VAR = new-value
+Global: TARGET_ENV_VAR = new-value
+target: TARGET_NEW_VAR = new-value
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.18 src/usr.bin/make/unit-tests/varmod-assign.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.18	Sun Dec 31 10:09:01 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Jan  7 11:42:22 2024
@@ -1,8 +1,10 @@
-# $NetBSD: varmod-assign.mk,v 1.18 2023/12/31 10:09:01 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.19 2024/01/07 11:42:22 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
 
+.if !make(target)
+
 all:	mod-assign-empty
 all:	mod-assign-parse
 all:	mod-assign-shell-error
@@ -162,7 +164,6 @@ ${VARNAME}=	initial-value	# Sets 'VAR.${
 .MAKEFLAGS: CMD_CMD_VAR=cmd-value
 CMD_GLOBAL_VAR=global-value
 export CMD_ENV_VAR=env-value
-
 .MAKEFLAGS: -dv
 # expect-reset
 # expect: Command: CMD_CMD_VAR = new-value
@@ -178,23 +179,30 @@ export CMD_ENV_VAR=env-value
 .endif
 .MAKEFLAGS: -d0
 
+# Run the 'target' test in a separate sub-make, with reduced debug logging.
+all: run-target
+run-target: .PHONY
+	@${MAKE} -r -f ${MAKEFILE} -dv target 2>&1 | grep ': TARGET_'
 
-# In target scope, assignments only happen in a few cases.  To extract the
-# debug log for this test, the debug log would have to be enabled for the
-# other targets as well, thus producing lots of irrelevant output.
+.else # make(target)
+
+# The commands of a target are evaluated in target scope.  An assignment
+# modifier that creates a new variable creates it in the target scope.
+# Existing variables are updated in their previous scope, and environment
+# variables are created in the global scope, as in other situations.
 #
-# Running './make -r -f varmod-assign.mk target | grep ": TARGET"' results in:
-#	target: TARGET_TARGET_VAR = new-value
-#	Global: TARGET_GLOBAL_VAR = new-value
-#	Global: TARGET_ENV_VAR = new-value
-#	target: TARGET_NEW_VAR = new-value
+# expect: target: TARGET_TARGET_VAR = new-value
+# expect: Global: TARGET_GLOBAL_VAR = new-value
+# expect: Global: TARGET_ENV_VAR = new-value
+# expect: target: TARGET_NEW_VAR = new-value
 .MAKEFLAGS: TARGET_CMD_VAR=cmd-value
 TARGET_GLOBAL_VAR=global-value
 export TARGET_ENV_VAR=env-value
-.MAKEFLAGS: ${make(target):?-dv:}
 target: .PHONY TARGET_TARGET_VAR=target-value
 	: ${TARGET_TARGET_VAR::=new-value}
 	: ${TARGET_CMD_VAR::=new-value}
 	: ${TARGET_GLOBAL_VAR::=new-value}
 	: ${TARGET_ENV_VAR::=new-value}
 	: ${TARGET_NEW_VAR::=new-value}
+
+.endif



CVS commit: src/usr.bin/make/unit-tests

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk

Log Message:
tests/make: test the '::=' modifier in target scope


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-assign.exp \
src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 02:07:44 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make: unit-tests handle TEST_MAKE:T != make

We need to allow for ${TEST_MAKE:T}[1-9]: etc when
TEST_MAKE is not 'make'


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.341 src/usr.bin/make/unit-tests/Makefile:1.342
--- src/usr.bin/make/unit-tests/Makefile:1.341	Sat Sep  9 16:41:04 2023
+++ src/usr.bin/make/unit-tests/Makefile	Sun Jan  7 02:07:44 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.341 2023/09/09 16:41:04 sjg Exp $
+# $NetBSD: Makefile,v 1.342 2024/01/07 02:07:44 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -747,6 +747,7 @@ _SED_CMDS+=	-e 's,${.OBJDIR},,g'
 _SED_CMDS+=	-e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
 _SED_CMDS+=	-e 's,${TEST_MAKE:S,.,\\.,g},make,'
 _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
+_SED_CMDS+=	-e 's,${TEST_MAKE:T:S,.,\\.,g}\(\[[1-9][0-9]*\]:\),make\1,'
 _SED_CMDS+=	-e 's,/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
 _SED_CMDS+=	-e '/MAKE_VERSION/d'



CVS commit: src/usr.bin/make/unit-tests

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 02:07:44 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: Makefile

Log Message:
make: unit-tests handle TEST_MAKE:T != make

We need to allow for ${TEST_MAKE:T}[1-9]: etc when
TEST_MAKE is not 'make'


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:36:45 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-op-shell.mk

Log Message:
tests/make: test long shell commands via Cmd_Exec


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-op-shell.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-op-shell.mk
diff -u src/usr.bin/make/unit-tests/var-op-shell.mk:1.7 src/usr.bin/make/unit-tests/var-op-shell.mk:1.8
--- src/usr.bin/make/unit-tests/var-op-shell.mk:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-op-shell.mk	Fri Jan  5 23:36:45 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-shell.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: var-op-shell.mk,v 1.8 2024/01/05 23:36:45 rillig Exp $
 #
 # Tests for the != variable assignment operator, which runs its right-hand
 # side through the shell.
@@ -91,4 +91,22 @@ OUTPUT!=	echo ''
 OUTPUT!=	echo ''
 .MAKEFLAGS: -d0
 
+
+# Since main.c 1.607 from 2024-01-05, long shell commands are not run directly
+# via '$shell -c $command', they are first written to a temporary file that is
+# then fed to the shell via '$shell $tmpfile'.
+OUTPUT_SHORT!=	echo "$$0"
+OUTPUT_LONG!=	echo "$$0" || : ${:U:range=1000}
+# When running '$shell -c $command', '$0' in the shell evaluates to the name
+# of the shell.
+.if ${OUTPUT_SHORT} != ${.SHELL:T}
+.  error
+.endif
+# When running '$shell $tmpfile', '$0' in the shell evaluates to the name of
+# the temporary file.
+.if !${OUTPUT_LONG:M*/make*}
+.  error
+.endif
+
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:36:45 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: var-op-shell.mk

Log Message:
tests/make: test long shell commands via Cmd_Exec


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-op-shell.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 31 10:09:01 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.mk

Log Message:
tests/make: finish incomplete sentence in test for assignment modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.17 src/usr.bin/make/unit-tests/varmod-assign.mk:1.18
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.17	Fri Dec 29 15:47:03 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Dec 31 10:09:01 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.17 2023/12/29 15:47:03 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.18 2023/12/31 10:09:01 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -155,8 +155,10 @@ ${VARNAME}=	initial-value	# Sets 'VAR.${
 .MAKEFLAGS: -d0
 
 
-# Conditional directives are evaluated in command line scope.  Any assignment
-# modifiers in these conditions create or
+# Conditional directives are evaluated in command line scope.  An assignment
+# modifier that creates a new variable creates it in the command line scope.
+# Existing variables are updated in their previous scope, and environment
+# variables are created in the global scope, as in other situations.
 .MAKEFLAGS: CMD_CMD_VAR=cmd-value
 CMD_GLOBAL_VAR=global-value
 export CMD_ENV_VAR=env-value
@@ -181,8 +183,7 @@ export CMD_ENV_VAR=env-value
 # debug log for this test, the debug log would have to be enabled for the
 # other targets as well, thus producing lots of irrelevant output.
 #
-# Running './make -r -f varmod-assign.mk target' results in:
-#	target: TARGET_TARGET_VAR = target-value
+# Running './make -r -f varmod-assign.mk target | grep ": TARGET"' results in:
 #	target: TARGET_TARGET_VAR = new-value
 #	Global: TARGET_GLOBAL_VAR = new-value
 #	Global: TARGET_ENV_VAR = new-value
@@ -191,7 +192,7 @@ export CMD_ENV_VAR=env-value
 TARGET_GLOBAL_VAR=global-value
 export TARGET_ENV_VAR=env-value
 .MAKEFLAGS: ${make(target):?-dv:}
-target: TARGET_TARGET_VAR=target-value
+target: .PHONY TARGET_TARGET_VAR=target-value
 	: ${TARGET_TARGET_VAR::=new-value}
 	: ${TARGET_CMD_VAR::=new-value}
 	: ${TARGET_GLOBAL_VAR::=new-value}



CVS commit: src/usr.bin/make/unit-tests

2023-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 31 10:09:01 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.mk

Log Message:
tests/make: finish incomplete sentence in test for assignment modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 15:47:03 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk

Log Message:
tests/make: test the '::=' assignment modifier


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.17 src/usr.bin/make/unit-tests/varmod-assign.exp:1.18
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.17	Tue Nov 30 20:48:01 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Fri Dec 29 15:47:03 2023
@@ -12,6 +12,31 @@ Var_Parse: ${${VARNAME}} != "assigned-va
 Var_Parse: ${VARNAME}} != "assigned-value" (eval-defined)
 Global: .MAKEFLAGS =  -r -k -d v -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0
+Var_Parse: ${CMD_CMD_VAR::=new-value}  || ${CMD_GLOBAL_VAR::=new-value}  || ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_CMD_VAR::...} on value "cmd-value"
+Modifier part: "new-value"
+Command: CMD_CMD_VAR = new-value
+Global: .MAKEOVERRIDES =  FIRST LAST LAST LAST APPENDED RAN RAN RAN IT1 THEN1 IE2 ELSE2 CMD_CMD_VAR CMD_CMD_VAR
+Result of ${CMD_CMD_VAR::=new-value} is ""
+Var_Parse: ${CMD_GLOBAL_VAR::=new-value}  || ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_GLOBAL_VAR::...} on value "global-value"
+Modifier part: "new-value"
+Global: CMD_GLOBAL_VAR = new-value
+Result of ${CMD_GLOBAL_VAR::=new-value} is ""
+Var_Parse: ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_ENV_VAR::...} on value "env-value"
+Modifier part: "new-value"
+Global: CMD_ENV_VAR = new-value
+Result of ${CMD_ENV_VAR::=new-value} is ""
+Var_Parse: ${CMD_NEW_VAR::=new-value}" (eval)
+Evaluating modifier ${CMD_NEW_VAR::...} on value "" (eval, undefined)
+Modifier part: "new-value"
+Global: ignoring delete 'CMD_NEW_VAR' as it is not found
+Command: CMD_NEW_VAR = new-value
+Global: .MAKEOVERRIDES =  FIRST LAST LAST LAST APPENDED RAN RAN RAN IT1 THEN1 IE2 ELSE2 CMD_CMD_VAR CMD_CMD_VAR CMD_NEW_VAR
+Result of ${CMD_NEW_VAR::=new-value} is "" (eval, undefined)
+Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d
+Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0
 make: Bad modifier ":" for variable ""
 mod-assign-empty: value}
 make: Bad modifier ":" for variable ""

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.16 src/usr.bin/make/unit-tests/varmod-assign.mk:1.17
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.16	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Fri Dec 29 15:47:03 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.16 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.17 2023/12/29 15:47:03 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -7,34 +7,38 @@ all:	mod-assign-empty
 all:	mod-assign-parse
 all:	mod-assign-shell-error
 
-# The modifier '::?=' applies the assignment operator '?=' 3 times. The
+# In the following loop expression,
+# the '::?=' modifier applies the assignment operator '?=' 3 times. The
 # operator '?=' only has an effect for the first time, therefore the variable
 # FIRST ends up with the value 1.
 .if "${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}" != " first=1"
 .  error
 .endif
 
-# The modifier '::=' applies the assignment operator '=' 3 times. The
+# In the following loop expression,
+# the modifier '::=' applies the assignment operator '=' 3 times. The
 # operator '=' overwrites the previous value, therefore the variable LAST ends
 # up with the value 3.
 .if "${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}" != " last=3"
 .  error
 .endif
 
-# The modifier '::+=' applies the assignment operator '+=' 3 times. The
+# In the following loop expression,
+# the modifier '::+=' applies the assignment operator '+=' 3 times. The
 # operator '+=' appends 3 times to the variable, therefore the variable
 # APPENDED ends up with the value "1 2 3".
 .if "${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}" != " appended=1 2 3"
 .  error
 .endif
 
-# The modifier '::!=' applies the assignment operator '!=' 3 times. Just as
+# In the following loop expression,
+# the modifier '::!=' applies the assignment operator '!=' 3 times. Just as
 # with the modifier '::=', the last value is stored in the RAN variable.
 .if "${1 2 3:L:@i@${RAN::!=${i:%=echo '<%>';}}@} ran=${RAN}" != " ran=<3>"
 .  error
 .endif
 
-# The assignments were performed as part of .if conditions and thus happened
+# When a '::=' modifier is 

CVS commit: src/usr.bin/make/unit-tests

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 15:47:03 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-assign.exp varmod-assign.mk

Log Message:
tests/make: test the '::=' assignment modifier


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-assign.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 20 09:46:00 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: vardebug.exp vardebug.mk

Log Message:
tests/make: add the expected output to the test for variable debugging


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/vardebug.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/vardebug.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 20 09:46:00 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: vardebug.exp vardebug.mk

Log Message:
tests/make: add the expected output to the test for variable debugging


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/vardebug.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/vardebug.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/vardebug.exp
diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.33 src/usr.bin/make/unit-tests/vardebug.exp:1.34
--- src/usr.bin/make/unit-tests/vardebug.exp:1.33	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/vardebug.exp	Wed Dec 20 09:46:00 2023
@@ -54,11 +54,11 @@ Var_Parse: ${:Uvariable:unknown} (eval-d
 Evaluating modifier ${:U...} on value "" (eval-defined, undefined)
 Result of ${:Uvariable} is "variable" (eval-defined, defined)
 Evaluating modifier ${:u...} on value "variable" (eval-defined, defined)
-make: "vardebug.mk" line 46: Unknown modifier "unknown"
+make: "vardebug.mk" line 63: Unknown modifier "unknown"
 Result of ${:unknown} is error (eval-defined, defined)
-make: "vardebug.mk" line 46: Malformed conditional (${:Uvariable:unknown})
+make: "vardebug.mk" line 63: Malformed conditional (${:Uvariable:unknown})
 Var_Parse: ${UNDEFINED} (eval-defined)
-make: "vardebug.mk" line 56: Malformed conditional (${UNDEFINED})
+make: "vardebug.mk" line 73: Malformed conditional (${UNDEFINED})
 Global: ignoring delete '.SHELL' as it is not found
 Command: .SHELL = 
 Command: ignoring '.SHELL = overwritten' as it is read-only

Index: src/usr.bin/make/unit-tests/vardebug.mk
diff -u src/usr.bin/make/unit-tests/vardebug.mk:1.8 src/usr.bin/make/unit-tests/vardebug.mk:1.9
--- src/usr.bin/make/unit-tests/vardebug.mk:1.8	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/vardebug.mk	Wed Dec 20 09:46:00 2023
@@ -1,32 +1,46 @@
-# $NetBSD: vardebug.mk,v 1.8 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: vardebug.mk,v 1.9 2023/12/20 09:46:00 rillig Exp $
 #
 # Demonstrates the debugging output for var.c.
 
 .MAKEFLAGS: -dv FROM_CMDLINE=
 
+# expect: Global: VAR = added
 VAR=		added		# VarAdd
+# expect: Global: VAR = overwritten
 VAR=		overwritten	# Var_Set
-.undef VAR			# Var_Delete (found)
-.undef VAR			# Var_Delete (not found)
+# expect: Global: delete VAR
+.undef VAR
+# expect: Global: ignoring delete 'VAR' as it is not found
+.undef VAR
 
 # The variable with the empty name cannot be set at all.
+# expect: Global: ignoring ' = empty name' as the variable name '${:U}' expands to empty
 ${:U}=		empty name	# Var_Set
+# expect: Global: ignoring ' += empty name' as the variable name '${:U}' expands to empty
 ${:U}+=		empty name	# Var_Append
 
 FROM_CMDLINE=	overwritten	# Var_Set (ignored)
 
+# expect: Global: VAR = 1
 VAR=		1
+# expect: Global: VAR = 1 2
 VAR+=		2
+# expect: Global: VAR = 1 2 3
 VAR+=		3
 
+# expect: Pattern for ':M' is "[2]"
+# expect: Result of ${VAR:M[2]} is "2"
 .if ${VAR:M[2]}			# ModifyWord_Match
 .endif
-.if ${VAR:N[2]}			# ModifyWord_NoMatch (no debug output)
+# expect: Pattern for ':N' is "[2]"
+# expect: Result of ${VAR:N[2]} is "1 3"
+.if ${VAR:N[2]}			# ModifyWord_NoMatch
 .endif
 
 .if ${VAR:S,2,two,}		# ParseModifierPart
 .endif
 
+# expect: Result of ${VAR:Q} is "1\ 2\ 3"
 .if ${VAR:Q}			# VarQuote
 .endif
 
@@ -34,13 +48,16 @@ VAR+=		3
 .endif
 
 # ApplyModifiers, "Got ..."
+# expect: Result of ${:Mvalu[e]} is "value" (eval-defined, defined)
 .if ${:Uvalue:${:UM*e}:Mvalu[e]}
 .endif
 
+# expect: Global: delete VAR
 .undef ${:UVAR}			# Var_Delete
 
 # When ApplyModifiers results in an error, this appears in the debug log
 # as "is error", without surrounding quotes.
+# expect: Result of ${:unknown} is error (eval-defined, defined)
 # expect+2: Malformed conditional (${:Uvariable:unknown})
 # expect+1: Unknown modifier "unknown"
 .if ${:Uvariable:unknown}
@@ -59,9 +76,7 @@ VAR+=		3
 # By default, .SHELL is not defined and thus can be set.  As soon as it is
 # accessed, it is initialized in the command line scope (during VarFind),
 # where it is set to read-only.  Assigning to it is ignored.
+# expect: Command: ignoring '.SHELL = overwritten' as it is read-only
 .MAKEFLAGS: .SHELL=overwritten
 
 .MAKEFLAGS: -d0
-
-all:
-	@:



CVS commit: src/usr.bin/make/unit-tests

2023-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 20 08:42:10 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-readonly.exp var-readonly.mk

Log Message:
tests/make: demonstrate confusing debug log for read-only variables

The message 'delete %s' that occurs above the 'readOnly' looks as if the
variable would indeed be deleted.  The wording in the 'readOnly' line is
unclear.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-readonly.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-readonly.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 20 08:42:10 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-readonly.exp var-readonly.mk

Log Message:
tests/make: demonstrate confusing debug log for read-only variables

The message 'delete %s' that occurs above the 'readOnly' looks as if the
variable would indeed be deleted.  The wording in the 'readOnly' line is
unclear.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-readonly.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-readonly.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-readonly.exp
diff -u src/usr.bin/make/unit-tests/var-readonly.exp:1.1 src/usr.bin/make/unit-tests/var-readonly.exp:1.2
--- src/usr.bin/make/unit-tests/var-readonly.exp:1.1	Tue Jan 24 00:20:00 2023
+++ src/usr.bin/make/unit-tests/var-readonly.exp	Wed Dec 20 08:42:10 2023
@@ -1 +1,5 @@
+Global: delete N
+Global: delete N (readOnly)
+Global: .MAKEFLAGS =  -r -k -d v -d
+Global: .MAKEFLAGS =  -r -k -d v -d 0
 exit status 0

Index: src/usr.bin/make/unit-tests/var-readonly.mk
diff -u src/usr.bin/make/unit-tests/var-readonly.mk:1.3 src/usr.bin/make/unit-tests/var-readonly.mk:1.4
--- src/usr.bin/make/unit-tests/var-readonly.mk:1.3	Mon Jun 19 15:37:48 2023
+++ src/usr.bin/make/unit-tests/var-readonly.mk	Wed Dec 20 08:42:10 2023
@@ -1,4 +1,4 @@
-# $NetBSD: var-readonly.mk,v 1.3 2023/06/19 15:37:48 sjg Exp $
+# $NetBSD: var-readonly.mk,v 1.4 2023/12/20 08:42:10 rillig Exp $
 
 # the answer
 N = 42
@@ -10,10 +10,12 @@ N = 666
 .endif
 
 # undef should fail
+.MAKEFLAGS: -dv
 .undef N
 .ifndef N
 .error N should not be undef'd
 .endif
+.MAKEFLAGS: -d0
 
 .NOREADONLY: N
 # now we can change it



CVS commit: src/usr.bin/make/unit-tests

2023-12-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 18 11:13:51 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-subst-regex.mk varmod-subst.mk

Log Message:
tests/make: fix typo in test for ':C' modifier

The expression ${U:...} was always undefined, as there was no variable
named 'U'; the intended form was ${:U:...}.  Due to this typo, the
comments in the tests for the ':S' and the ':C' modifier contradicted
each other.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-subst.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-subst-regex.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.10 src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.10	Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.mk	Mon Dec 18 11:13:51 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst-regex.mk,v 1.10 2023/12/17 14:07:22 rillig Exp $
+# $NetBSD: varmod-subst-regex.mk,v 1.11 2023/12/18 11:13:51 rillig Exp $
 #
 # Tests for the :C,from,to, variable modifier.
 
@@ -88,23 +88,43 @@ all: unmatched-subexpression
 # Like the ':S' modifier, the ':C' modifier matches on an expression
 # that contains no words at all, but only if the regular expression matches an
 # empty string, for example, when the regular expression is anchored at the
-# beginning or the end of the word.
-.if "<${U:S,^,prefix,}> <${:U:C,^,prefix,}>" != "<> "
+# beginning or the end of the word.  An unanchored regular expression that
+# matches the empty string is uncommon in practice, as it would match before
+# each character of the word.
+.if "<${:U:S,,unanchored,}> <${:U:C,.?,unanchored,}>" != "<> "
 .  error
 .endif
-.if "<${U:S,$,suffix,}> <${:U:C,$,suffix,}>" != "<> "
+.if "<${:U:S,^,prefix,}> <${:U:C,^,prefix,}>" != " "
 .  error
 .endif
-.if "<${U:S,^$,whole,}> <${:U:C,^$,whole,}>" != "<> "
+.if "<${:U:S,$,suffix,}> <${:U:C,$,suffix,}>" != " "
 .  error
 .endif
-.if "<${U:S,^,prefix,g}> <${:U:C,^,prefix,g}>" != "<> "
+.if "<${:U:S,^$,whole,}> <${:U:C,^$,whole,}>" != " "
 .  error
 .endif
-.if "<${U:S,$,suffix,g}> <${:U:C,$,suffix,g}>" != "<> "
+.if "<${:U:S,,unanchored,g}> <${:U:C,.?,unanchored,g}>" != "<> "
 .  error
 .endif
-.if "<${U:S,^$,whole,g}> <${:U:C,^$,whole,g}>" != "<> "
+.if "<${:U:S,^,prefix,g}> <${:U:C,^,prefix,g}>" != " "
+.  error
+.endif
+.if "<${:U:S,$,suffix,g}> <${:U:C,$,suffix,g}>" != " "
+.  error
+.endif
+.if "<${:U:S,^$,whole,g}> <${:U:C,^$,whole,g}>" != " "
+.  error
+.endif
+.if "<${:U:S,,unanchored,W}> <${:U:C,.?,unanchored,W}>" != "<> "
+.  error
+.endif
+.if "<${:U:S,^,prefix,W}> <${:U:C,^,prefix,W}>" != " "
+.  error
+.endif
+.if "<${:U:S,$,suffix,W}> <${:U:C,$,suffix,W}>" != " "
+.  error
+.endif
+.if "<${:U:S,^$,whole,W}> <${:U:C,^$,whole,W}>" != " "
 .  error
 .endif
 

Index: src/usr.bin/make/unit-tests/varmod-subst.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.13 src/usr.bin/make/unit-tests/varmod-subst.mk:1.14
--- src/usr.bin/make/unit-tests/varmod-subst.mk:1.13	Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/varmod-subst.mk	Mon Dec 18 11:13:51 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst.mk,v 1.13 2023/12/17 14:07:22 rillig Exp $
+# $NetBSD: varmod-subst.mk,v 1.14 2023/12/18 11:13:51 rillig Exp $
 #
 # Tests for the :S,from,to, variable modifier.
 
@@ -142,8 +142,9 @@ WORDS=		sequences of letters
 .endif
 
 
-# In an empty expression, the ':S' modifier matches a single time if the
-# search string is anchored at the beginning or at the end.
+# In an empty expression, the ':S' modifier matches a single time, but only if
+# the search string is empty and anchored at either the beginning or the end
+# of the word.
 .if ${:U:S,,out-of-nothing,} != ""
 .  error
 .endif
@@ -156,6 +157,30 @@ WORDS=		sequences of letters
 .if ${:U:S,^$,out-of-nothing,} != "out-of-nothing"
 .  error
 .endif
+.if ${:U:S,,out-of-nothing,g} != ""
+.  error
+.endif
+.if ${:U:S,^,out-of-nothing,g} != "out-of-nothing"
+.  error
+.endif
+.if ${:U:S,$,out-of-nothing,g} != "out-of-nothing"
+.  error
+.endif
+.if ${:U:S,^$,out-of-nothing,g} != "out-of-nothing"
+.  error
+.endif
+.if ${:U:S,,out-of-nothing,W} != ""
+.  error
+.endif
+.if ${:U:S,^,out-of-nothing,W} != "out-of-nothing"
+.  error
+.endif
+.if ${:U:S,$,out-of-nothing,W} != "out-of-nothing"
+.  error
+.endif
+.if ${:U:S,^$,out-of-nothing,W} != "out-of-nothing"
+.  error
+.endif
 
 
 mod-subst:



CVS commit: src/usr.bin/make/unit-tests

2023-12-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Dec 18 11:13:51 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-subst-regex.mk varmod-subst.mk

Log Message:
tests/make: fix typo in test for ':C' modifier

The expression ${U:...} was always undefined, as there was no variable
named 'U'; the intended form was ${:U:...}.  Due to this typo, the
comments in the tests for the ':S' and the ':C' modifier contradicted
each other.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-subst.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 23:19:02 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: test the fast code path for ':M' patterns like '*.c'


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.13 src/usr.bin/make/unit-tests/varmod-match.exp:1.14
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.13	Sun Dec 17 00:19:11 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sun Dec 17 23:19:02 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 268: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 276: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 284: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 292: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 301: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 315: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 323: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 335: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 343: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 343: Unknown modifier "]"
-make: "varmod-match.mk" line 343: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 289: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 297: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 305: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 322: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 336: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 344: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 356: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 364: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 364: Unknown modifier "]"
+make: "varmod-match.mk" line 364: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.19 src/usr.bin/make/unit-tests/varmod-match.mk:1.20
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.19	Sun Dec 17 00:19:11 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sun Dec 17 23:19:02 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.19 2023/12/17 00:19:11 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.20 2023/12/17 23:19:02 rillig Exp $
 #
 # Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
@@ -53,6 +53,27 @@
 .  error
 .endif
 
+# Test the fast code path for '*' followed by a regular character.
+.if ${:U file.c file.*c file.h file\.c :M*.c} != "file.c file\\.c"
+.  error
+.endif
+# Ensure that the fast code path correctly handles the backslash.
+.if ${:U file.c file.*c file.h file\.c :M*\.c} != "file.c file\\.c"
+.  error
+.endif
+# Ensure that the fast code path correctly handles '\*'.
+.if ${:U file.c file.*c file.h file\.c :M*\*c} != "file.*c"
+.  error
+.endif
+# Ensure that the partial match '.c' doesn't confuse the fast code path.
+.if ${:U file.c.cc file.cc.cc file.cc.c :M*.cc} != "file.c.cc file.cc.cc"
+.  error
+.endif
+# Ensure that the substring '.cc' doesn't confuse the fast code path for '.c'.
+.if ${:U file.c.cc file.cc.cc file.cc.c :M*.c} != "file.cc.c"
+.  error
+.endif
+
 
 # 2. Character lists and character ranges
 #



CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 23:19:02 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: test the fast code path for ':M' patterns like '*.c'


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 14:07:22 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk var-scope-local-legacy.exp
var-scope-local-legacy.mk varmod-mtime.mk varmod-range.exp
varmod-range.mk varmod-subst-regex.mk varmod-subst.mk

Log Message:
tests/make: extend tests for include guards and empty expressions


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.15 -r1.16 \
src/usr.bin/make/unit-tests/directive-include-guard.mk
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/var-scope-local-legacy.exp \
src/usr.bin/make/unit-tests/var-scope-local-legacy.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-mtime.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-range.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-range.mk \
src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-subst.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.13 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.14
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.13	Sun Dec 17 09:17:16 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Sun Dec 17 14:07:22 2023
@@ -99,4 +99,6 @@ Parse_PushInput: file target-name-parent
 Parse_PushInput: file target-name-parenthesized.tmp, line 1
 Parse_PushInput: file target-call-parenthesized.tmp, line 1
 Parse_PushInput: file target-call-parenthesized.tmp, line 1
+Parse_PushInput: file multiline.tmp, line 1
+Skipping 'multiline.tmp' because 'MULTILINE' is defined
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.15 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.16
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.15	Sun Dec 17 09:17:16 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Sun Dec 17 14:07:22 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.15 2023/12/17 09:17:16 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.16 2023/12/17 14:07:22 rillig Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -601,6 +601,20 @@ LINES.target-call-parenthesized= \
 # expect: Parse_PushInput: file target-call-parenthesized.tmp, line 1
 # expect: Parse_PushInput: file target-call-parenthesized.tmp, line 1
 
+# If the '.if' or '.ifndef' directive spans more than a single line, it is
+# still recognized as a guard condition.  This case is entirely uncommon, but
+# at the point where the guard condition is checked, line continuations have
+# already been converted to spaces.
+CASES+=	multiline
+LINES.multiline= \
+	'.\' \
+	'  ifndef \' \
+	'  MULTILINE' \
+	'MULTILINE=' \
+	'.endif'
+# expect: Parse_PushInput: file multiline.tmp, line 1
+# expect: Skipping 'multiline.tmp' because 'MULTILINE' is defined
+
 
 # Now run all test cases by including each of the files twice and looking at
 # the debug output.  The files that properly guard against multiple inclusion

Index: src/usr.bin/make/unit-tests/var-scope-local-legacy.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local-legacy.exp:1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.exp:1.3
--- src/usr.bin/make/unit-tests/var-scope-local-legacy.exp:1.2	Tue Sep 27 19:18:45 2022
+++ src/usr.bin/make/unit-tests/var-scope-local-legacy.exp	Sun Dec 17 14:07:22 2023
@@ -2,5 +2,5 @@
 : XY=undef_
 : AF=undef_
 : %D=undef_ %F=undef_
-: @D=._ @F=all_
+: @D=global-value_ @F=all_
 exit status 0
Index: src/usr.bin/make/unit-tests/var-scope-local-legacy.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local-legacy.mk:1.2 src/usr.bin/make/unit-tests/var-scope-local-legacy.mk:1.3
--- src/usr.bin/make/unit-tests/var-scope-local-legacy.mk:1.2	Tue Sep 27 19:18:45 2022
+++ src/usr.bin/make/unit-tests/var-scope-local-legacy.mk	Sun Dec 17 14:07:22 2023
@@ -1,7 +1,24 @@
-# $NetBSD: var-scope-local-legacy.mk,v 1.2 2022/09/27 19:18:45 rillig Exp $
+# $NetBSD: var-scope-local-legacy.mk,v 1.3 2023/12/17 14:07:22 rillig Exp $
 #
 # Tests for legacy target-local variables, such as ${ <${:U:C,^,prefix,}>" != "<> "
 .  error
 .endif
@@ -126,7 +126,7 @@ mod-regex-limits:
 	@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}
 	@echo $@:22-ok:${:U1 23 456:C,(.)(.),\2\2,:Q}
 	# The :C modifier only handles single-digit capturing groups,
-	# which is more than enough for daily use.
+	# which is enough for all practical use cases.
 	@echo 

CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 09:44:00 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: check-expect.lua cond-op-and.mk
cond-op-or.mk deptgt.mk directive-export-gmake.mk
directive-for-errors.mk directive-warning.mk

Log Message:
tests/make: in 'expect' lines, require the complete text of the line


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/check-expect.lua \
src/usr.bin/make/unit-tests/directive-for-errors.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-op-and.mk \
src/usr.bin/make/unit-tests/directive-export-gmake.mk \
src/usr.bin/make/unit-tests/directive-warning.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-op-or.mk
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/deptgt.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 09:17:16 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: add tests for spacing in multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.12 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.13
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.12	Thu Oct 19 18:24:33 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Sun Dec 17 09:17:16 2023
@@ -14,10 +14,16 @@ Parse_PushInput: file variable-if-reuse.
 Skipping 'variable-if-reuse.tmp' because 'VARIABLE_IF' is defined
 Parse_PushInput: file variable-if-triple-negation.tmp, line 1
 Parse_PushInput: file variable-if-triple-negation.tmp, line 1
+Parse_PushInput: file variable-if-spaced.tmp, line 1
+Parse_PushInput: file variable-if-spaced.tmp, line 1
+Parse_PushInput: file variable-if-parenthesized.tmp, line 1
+Parse_PushInput: file variable-if-parenthesized.tmp, line 1
 Parse_PushInput: file variable-ifdef-negated.tmp, line 1
 Parse_PushInput: file variable-ifdef-negated.tmp, line 1
 Parse_PushInput: file variable-name-mismatch.tmp, line 1
 Parse_PushInput: file variable-name-mismatch.tmp, line 1
+Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1
+Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1
 Parse_PushInput: file variable-name-exclamation.tmp, line 1
 Parse_PushInput: file variable-name-exclamation.tmp, line 1
 Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1
@@ -89,4 +95,8 @@ Parse_PushInput: file target-already-def
 Skipping 'target-already-defined.tmp' because 'target-already-defined' is defined
 Parse_PushInput: file target-name-exclamation.tmp, line 1
 Parse_PushInput: file target-name-exclamation.tmp, line 1
+Parse_PushInput: file target-name-parenthesized.tmp, line 1
+Parse_PushInput: file target-name-parenthesized.tmp, line 1
+Parse_PushInput: file target-call-parenthesized.tmp, line 1
+Parse_PushInput: file target-call-parenthesized.tmp, line 1
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.14 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.15
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.14	Sun Dec 17 08:53:55 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Sun Dec 17 09:17:16 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.14 2023/12/17 08:53:55 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.15 2023/12/17 09:17:16 rillig Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -111,6 +111,26 @@ LINES.variable-if-triple-negation= \
 # expect: Parse_PushInput: file variable-if-triple-negation.tmp, line 1
 # expect: Parse_PushInput: file variable-if-triple-negation.tmp, line 1
 
+# If the guard variable is enclosed in spaces, it does not have an effect, as
+# that form is not common in practice.
+CASES+=	variable-if-spaced
+LINES.variable-if-spaced= \
+	'.if !defined( VARIABLE_IF_SPACED )' \
+	'VARIABLE_IF_SPACED=' \
+	'.endif'
+# expect: Parse_PushInput: file variable-if-spaced.tmp, line 1
+# expect: Parse_PushInput: file variable-if-spaced.tmp, line 1
+
+# If the guard variable condition is enclosed in parentheses, it does not have
+# an effect, as that form is not common in practice.
+CASES+=	variable-if-parenthesized
+LINES.variable-if-parenthesized= \
+	'.if (!defined(VARIABLE_IF_PARENTHESIZED))' \
+	'VARIABLE_IF_PARENTHESIZED=' \
+	'.endif'
+# expect: Parse_PushInput: file variable-if-parenthesized.tmp, line 1
+# expect: Parse_PushInput: file variable-if-parenthesized.tmp, line 1
+
 # A conditional other than '.if' or '.ifndef' does not guard the file, even if
 # it is otherwise equivalent to the above accepted forms.
 CASES+=	variable-ifdef-negated
@@ -130,6 +150,16 @@ LINES.variable-name-mismatch= \
 # expect: Parse_PushInput: file variable-name-mismatch.tmp, line 1
 # expect: Parse_PushInput: file variable-name-mismatch.tmp, line 1
 
+# If the guard variable condition is enclosed in parentheses, it does not have
+# an effect, as that form is not common in practice.
+CASES+=	variable-ifndef-parenthesized
+LINES.variable-ifndef-parenthesized= \
+	'.ifndef (VARIABLE_IFNDEF_PARENTHESIZED)' \
+	'VARIABLE_IFNDEF_PARENTHESIZED=' \
+	'.endif'
+# expect: Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1
+# expect: Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 

CVS commit: src/usr.bin/make/unit-tests

2023-12-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 09:17:16 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: add tests for spacing in multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 00:19:11 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: add basic tests for the ':M' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.12 src/usr.bin/make/unit-tests/varmod-match.exp:1.13
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.12	Sat Dec 16 23:40:33 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sun Dec 17 00:19:11 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 246: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 254: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 262: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 271: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 285: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 293: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 305: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 313: Unknown modifier "]"
-make: "varmod-match.mk" line 313: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 268: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 276: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 284: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 292: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 301: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 315: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 323: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 335: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 343: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 343: Unknown modifier "]"
+make: "varmod-match.mk" line 343: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.18 src/usr.bin/make/unit-tests/varmod-match.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.18	Sat Dec 16 23:38:35 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sun Dec 17 00:19:11 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.18 2023/12/16 23:38:35 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.19 2023/12/17 00:19:11 rillig Exp $
 #
 # Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
@@ -12,8 +12,10 @@
 # 5. Performance
 # 6. Error handling
 # 7. Historical bugs
+#
+# See ApplyModifier_Match, ParseModifier_Match, ModifyWord_Match and
+# Str_Match.
 
-NUMBERS=	One Two Three Four five six seven
 
 # 1. Pattern characters '*', '?' and '\'
 #
@@ -21,7 +23,35 @@ NUMBERS=	One Two Three Four five six sev
 #	?	matches 1 character
 #	\x	matches the character 'x'
 
-# TODO
+# The pattern is anchored both at the beginning and at the end of the word.
+# Since the pattern 'e' does not contain any pattern matching characters, it
+# matches exactly the word 'e', twice.
+.if ${a c e aa cc ee e f g:L:Me} != "e e"
+.  error
+.endif
+
+# The pattern character '?' matches exactly 1 character, the pattern character
+# '*' matches 0 or more characters.  The whole pattern matches all words that
+# start with 's' and have 3 or more characters.
+.if ${One Two Three Four five six seven:L:Ms??*} != "six seven"
+.  error
+.endif
+
+# Ensure that a pattern without placeholders only matches itself.
+.if ${a aa aaa b ba baa bab:L:Ma} != "a"
+.  error
+.endif
+
+# Ensure that a pattern that ends with '*' is properly anchored at the
+# beginning.
+.if ${a aa aaa b ba baa bab:L:Ma*} != "a aa aaa"
+.  error
+.endif
+
+# Ensure that a pattern that starts with 

CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 17 00:19:11 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: add basic tests for the ':M' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:40:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in expected test output for ':M'


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-match.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.11 src/usr.bin/make/unit-tests/varmod-match.exp:1.12
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.11	Sat Dec 16 23:38:35 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Dec 16 23:40:33 2023
@@ -1,14 +1,14 @@
-make: "varmod-match.mk" line 236: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 244: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 252: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 260: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 269: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 283: warning: Unfinished character list in pattern '?[\' of modifier ':M'
-make: "varmod-match.mk" line 291: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 303: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
-make: "varmod-match.mk" line 311: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 311: Unknown modifier "]"
-make: "varmod-match.mk" line 311: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 246: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 254: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 262: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 271: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 285: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 293: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 305: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 313: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 313: Unknown modifier "]"
+make: "varmod-match.mk" line 313: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1



CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:40:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in expected test output for ':M'


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-match.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:38:35 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: reorganize tests for the ':M' modifier

Add a table of contents.  Group the existing tests into sections.  Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-12-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 16 23:38:35 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp varmod-match.mk

Log Message:
tests/make: reorganize tests for the ':M' modifier

Add a table of contents.  Group the existing tests into sections.  Fix
the pattern of the test for the malformed ':M[\' modifier, now in line
283.

Note that the tests for the pattern characters '*?\' are missing.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-match.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.10 src/usr.bin/make/unit-tests/varmod-match.exp:1.11
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.10	Fri Jun 23 04:56:54 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Dec 16 23:38:35 2023
@@ -1,25 +1,14 @@
-CondParser_Eval: ${NUMBERS:M[A-Z]*} != "One Two Three Four"
-Comparing "One Two Three Four" != "One Two Three Four"
-CondParser_Eval: ${NUMBERS:M[^A-Z]*} != "five six seven"
-Comparing "five six seven" != "five six seven"
-CondParser_Eval: ${NUMBERS:M[^s]*[ex]} != "One Three five"
-Comparing "One Three five" != "One Three five"
-CondParser_Eval: ${:U:Mb}
-CondParser_Eval: ${:U..b:M*?*?*?*?*?a}
-CondParser_Eval: ${:Ua \$ sign:M*$$*} != "\$"
-Comparing "$" != "$"
-CondParser_Eval: ${:Ua \$ sign any-asterisk:M*\$*} != "any-asterisk"
-Comparing "any-asterisk" != "any-asterisk"
-make: "varmod-match.mk" line 162: warning: Unfinished character list in pattern '[' of modifier ':M'
-make: "varmod-match.mk" line 162: Unknown modifier "]"
-make: "varmod-match.mk" line 162: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
-make: "varmod-match.mk" line 205: warning: Unfinished character list in pattern 'a[' of modifier ':M'
-make: "varmod-match.mk" line 213: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
-make: "varmod-match.mk" line 221: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 229: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 238: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
-make: "varmod-match.mk" line 258: warning: Unfinished character range in pattern '[x-' of modifier ':M'
-make: "varmod-match.mk" line 270: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 236: warning: Unfinished character list in pattern 'a[' of modifier ':M'
+make: "varmod-match.mk" line 244: warning: Unfinished character list in pattern 'a[^' of modifier ':M'
+make: "varmod-match.mk" line 252: warning: Unfinished character list in pattern '[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 260: warning: Unfinished character list in pattern '*[-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 269: warning: Unfinished character list in pattern '[^-x1-3' of modifier ':M'
+make: "varmod-match.mk" line 283: warning: Unfinished character list in pattern '?[\' of modifier ':M'
+make: "varmod-match.mk" line 291: warning: Unfinished character range in pattern '[x-' of modifier ':M'
+make: "varmod-match.mk" line 303: warning: Unfinished character range in pattern '[^x-' of modifier ':M'
+make: "varmod-match.mk" line 311: warning: Unfinished character list in pattern '[' of modifier ':M'
+make: "varmod-match.mk" line 311: Unknown modifier "]"
+make: "varmod-match.mk" line 311: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-match.mk
diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.17 src/usr.bin/make/unit-tests/varmod-match.mk:1.18
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.17	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sat Dec 16 23:38:35 2023
@@ -1,97 +1,46 @@
-# $NetBSD: varmod-match.mk,v 1.17 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.18 2023/12/16 23:38:35 rillig Exp $
 #
-# Tests for the :M variable modifier, which filters words that match the
+# Tests for the ':M' modifier, which keeps only those words that match the
 # given pattern.
 #
-# See ApplyModifier_Match, ParseModifier_Match and ModifyWord_Match.
-
-.MAKEFLAGS: -dc
+# Table of contents
+#
+# 1. Pattern characters '*', '?' and '\'
+# 2. Character lists and character ranges
+# 3. Parsing and escaping
+# 4. Interaction with other modifiers
+# 5. Performance
+# 6. Error handling
+# 7. Historical bugs
 
 NUMBERS=	One Two Three Four five six seven
 
-# Only keep words that start with an 

CVS commit: src/usr.bin/make/unit-tests

2023-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec  6 22:28:20 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk

Log Message:
tests/make: show how global variables are unaffected by .for loops


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-for.exp
diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.20 src/usr.bin/make/unit-tests/directive-for.exp:1.21
--- src/usr.bin/make/unit-tests/directive-for.exp:1.20	Thu Oct 19 18:24:33 2023
+++ src/usr.bin/make/unit-tests/directive-for.exp	Wed Dec  6 22:28:20 2023
@@ -17,15 +17,15 @@ make: "directive-for.mk" line 146: }{ }{
 make: "directive-for.mk" line 166: invalid character ':' in .for loop variable name
 make: "directive-for.mk" line 173: invalid character '$' in .for loop variable name
 make: "directive-for.mk" line 185: invalid character '$' in .for loop variable name
-make: "directive-for.mk" line 196: Unknown modifier "Z"
-make: "directive-for.mk" line 197: XXX: Should not reach word1
-make: "directive-for.mk" line 197: XXX: Should not reach before--after
-make: "directive-for.mk" line 197: XXX: Should not reach word3
-make: "directive-for.mk" line 205: no iteration variables in for
-make: "directive-for.mk" line 231: 1 open conditional
-make: "directive-for.mk" line 247: for-less endfor
-make: "directive-for.mk" line 248: if-less endif
-make: "directive-for.mk" line 256: if-less endif
+make: "directive-for.mk" line 210: Unknown modifier "Z"
+make: "directive-for.mk" line 211: XXX: Should not reach word1
+make: "directive-for.mk" line 211: XXX: Should not reach before--after
+make: "directive-for.mk" line 211: XXX: Should not reach word3
+make: "directive-for.mk" line 219: no iteration variables in for
+make: "directive-for.mk" line 245: 1 open conditional
+make: "directive-for.mk" line 261: for-less endfor
+make: "directive-for.mk" line 262: if-less endif
+make: "directive-for.mk" line 270: if-less endif
 For: new loop 2
 For: end for 2
 For: end for 1
@@ -36,7 +36,7 @@ For: loop body with outer = o:
endfor
 For: end for 1
 For: loop body with inner = i:
-make: "directive-for.mk" line 304: newline-item=(a)
+make: "directive-for.mk" line 318: newline-item=(a)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/directive-for.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.23 src/usr.bin/make/unit-tests/directive-for.mk:1.24
--- src/usr.bin/make/unit-tests/directive-for.mk:1.23	Thu Oct 19 18:24:33 2023
+++ src/usr.bin/make/unit-tests/directive-for.mk	Wed Dec  6 22:28:20 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.23 2023/10/19 18:24:33 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.24 2023/12/06 22:28:20 rillig Exp $
 #
 # Tests for the .for directive.
 #
@@ -25,7 +25,7 @@ NUMBERS+=	${num}
 
 
 # The .for loop also works for multiple iteration variables.
-# This is something that the modifier :@ cannot do.
+# This is something that the modifier :@ cannot do as easily.
 .for name value in VARNAME value NAME2 value2
 ${name}=	${value}
 .endfor
@@ -189,6 +189,20 @@ INDIRECT=	direct
 .endfor
 
 
+# Regular global variables and the "variables" from the .for loop don't
+# interfere with each other.  In the following snippet, the variable 'DIRECT'
+# is used both as a global variable, as well as an iteration variable in the
+# .for loop.  The expression '${INDIRECT}' refers to the global variable, not
+# to the one from the .for loop.
+DIRECT=		global
+INDIRECT=	${DIRECT}
+.for DIRECT in iteration
+.  if "${DIRECT} ${INDIRECT}" != "iteration global"
+.error
+.  endif
+.endfor
+
+
 # XXX: A parse error or evaluation error in the items of the .for loop
 # should skip the whole loop.  As of 2023-05-09, the loop is expanded as
 # usual.



CVS commit: src/usr.bin/make/unit-tests

2023-12-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec  6 22:28:20 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk

Log Message:
tests/make: show how global variables are unaffected by .for loops


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/directive-for.exp
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 22:32:44 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-short.mk dep-var.mk
deptgt-makeflags.mk directive-for-escape.mk directive.mk
moderrs.exp moderrs.mk var-op-default.mk varmod-indirect.mk
varname-make_print_var_on_error-jobs.mk varparse-dynamic.mk
varparse-errors.mk

Log Message:
tests/make: replace 'variable expressions' with 'expressions'


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-short.mk \
src/usr.bin/make/unit-tests/directive-for-escape.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dep-var.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt-makeflags.mk \
src/usr.bin/make/unit-tests/directive.mk
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/moderrs.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-default.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varparse-dynamic.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varparse-errors.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 22:32:44 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-short.mk dep-var.mk
deptgt-makeflags.mk directive-for-escape.mk directive.mk
moderrs.exp moderrs.mk var-op-default.mk varmod-indirect.mk
varname-make_print_var_on_error-jobs.mk varparse-dynamic.mk
varparse-errors.mk

Log Message:
tests/make: replace 'variable expressions' with 'expressions'


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-short.mk \
src/usr.bin/make/unit-tests/directive-for-escape.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dep-var.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt-makeflags.mk \
src/usr.bin/make/unit-tests/directive.mk
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.exp
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/moderrs.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-default.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varparse-dynamic.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varparse-errors.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-short.mk
diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.22 src/usr.bin/make/unit-tests/cond-short.mk:1.23
--- src/usr.bin/make/unit-tests/cond-short.mk:1.22	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/cond-short.mk	Sun Nov 19 22:32:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.22 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.23 2023/11/19 22:32:44 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -11,7 +11,7 @@
 # Var_Parse got a new parameter named 'wantit'.  Since then it would have been
 # possible to skip evaluation of irrelevant expressions and only
 # parse them.  They were still evaluated though, the only difference to
-# relevant expressions was that in the irrelevant variable
+# relevant expressions was that in the irrelevant
 # expressions, undefined variables were allowed.  This allowed for conditions
 # like 'defined(VAR) && ${VAR:S,from,to,} != ""', which no longer produced an
 # error message 'Malformed conditional', but the irrelevant expression was
Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.22 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.23
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.22	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Sun Nov 19 22:32:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.22 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.23 2023/11/19 22:32:44 rillig Exp $
 #
 # Test escaping of special characters in the iteration values of a .for loop.
 # These values get expanded later using the :U variable modifier, and this
@@ -156,7 +156,7 @@ NUMBERS=	one two three
 .endfor
 
 # Before for.c 1.173 from 2023-05-08, the name of the iteration variable
-# could contain braces, which allowed to replace sequences of variable
+# could contain braces, which allowed to replace sequences of
 # expressions.  This possibility was neither intended nor documented.
 BASENAME=	one
 EXT=		.c

Index: src/usr.bin/make/unit-tests/dep-var.mk
diff -u src/usr.bin/make/unit-tests/dep-var.mk:1.9 src/usr.bin/make/unit-tests/dep-var.mk:1.10
--- src/usr.bin/make/unit-tests/dep-var.mk:1.9	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/dep-var.mk	Sun Nov 19 22:32:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: dep-var.mk,v 1.9 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: dep-var.mk,v 1.10 2023/11/19 22:32:44 rillig Exp $
 #
 # Tests for variable references in dependency declarations.
 #
@@ -63,7 +63,7 @@ INDIRECT_3=	indirect
 UNDEF1=	undef1
 DEF2=	def2
 
-# Cover the code in SuffExpandChildren that deals with malformed variable
+# Cover the code in SuffExpandChildren that deals with malformed
 # expressions.
 #
 # This seems to be an edge case that never happens in practice, and it would

Index: src/usr.bin/make/unit-tests/deptgt-makeflags.mk
diff -u src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.8 src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.9
--- src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.8	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/deptgt-makeflags.mk	Sun Nov 19 22:32:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-makeflags.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: deptgt-makeflags.mk,v 1.9 2023/11/19 22:32:44 rillig Exp $
 #
 # Tests for the special 

CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 21:47:52 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cmdline-undefined.mk comment.mk
cond-cmp-string.mk cond-cmp-unary.mk cond-eof.mk
cond-func-defined.exp cond-func-defined.mk cond-func-empty.mk
cond-func-exists.mk cond-func.mk cond-late.mk cond-short.mk
cond-token-number.mk cond-token-plain.exp cond-token-plain.mk
cond-token-string.exp cond-token-string.mk cond-token-var.mk
dep-var.mk deptgt-makeflags.mk deptgt.mk directive-else.mk
directive-for-empty.mk directive-for-errors.mk
directive-for-escape.mk directive-for-if.mk directive-ifmake.mk
lint.mk opt-debug-file.mk opt-debug-jobs.mk opt-debug-lint.mk
opt-debug-var.mk parse-var.mk sh-dots.mk var-op-assign.mk
var-op-default.mk var-op-expand.mk var-recursive.mk
var-scope-cmdline.mk var-scope-local.mk varmod-assign.mk
varmod-defined.mk varmod-edge.mk varmod-gmtime.mk varmod-ifelse.exp
varmod-ifelse.mk varmod-indirect.mk varmod-l-name-to-value.mk
varmod-localtime.mk varmod-loop-varname.mk varmod-loop.mk
varmod-match-escape.mk varmod-match.mk varmod-range.mk
varmod-subst-regex.mk varmod-sysv.mk varmod-to-separator.mk
varmod-undefined.mk varmod.mk varname-empty.mk varname.mk
varparse-errors.mk varparse-mod.mk varparse-undef-partial.mk

Log Message:
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity.  The wording in make's diagnostics will be changed in a
follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline-undefined.mk \
src/usr.bin/make/unit-tests/sh-dots.mk \
src/usr.bin/make/unit-tests/var-op-default.mk \
src/usr.bin/make/unit-tests/var-scope-cmdline.mk \
src/usr.bin/make/unit-tests/varparse-undef-partial.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/comment.mk \
src/usr.bin/make/unit-tests/cond-cmp-unary.mk \
src/usr.bin/make/unit-tests/cond-eof.mk \
src/usr.bin/make/unit-tests/opt-debug-jobs.mk \
src/usr.bin/make/unit-tests/var-recursive.mk \
src/usr.bin/make/unit-tests/varmod-loop-varname.mk
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-cmp-string.mk \
src/usr.bin/make/unit-tests/varmod-edge.mk \
src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-defined.exp \
src/usr.bin/make/unit-tests/cond-token-var.mk \
src/usr.bin/make/unit-tests/deptgt-makeflags.mk \
src/usr.bin/make/unit-tests/var-scope-local.mk \
src/usr.bin/make/unit-tests/varmod-l-name-to-value.mk \
src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.mk \
src/usr.bin/make/unit-tests/cond-token-string.exp \
src/usr.bin/make/unit-tests/var-op-assign.mk
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-func-empty.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-exists.mk \
src/usr.bin/make/unit-tests/directive-for-errors.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-func.mk \
src/usr.bin/make/unit-tests/varmod-localtime.mk \
src/usr.bin/make/unit-tests/varname.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-late.mk \
src/usr.bin/make/unit-tests/lint.mk
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-short.mk \
src/usr.bin/make/unit-tests/directive-for-escape.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-number.mk \
src/usr.bin/make/unit-tests/opt-debug-file.mk \
src/usr.bin/make/unit-tests/varname-empty.mk \
src/usr.bin/make/unit-tests/varparse-errors.mk
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-token-plain.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/cond-token-plain.mk \
src/usr.bin/make/unit-tests/var-op-expand.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.mk \
src/usr.bin/make/unit-tests/dep-var.mk \
src/usr.bin/make/unit-tests/directive-else.mk \
src/usr.bin/make/unit-tests/parse-var.mk \
src/usr.bin/make/unit-tests/varmod-range.mk \
src/usr.bin/make/unit-tests/varmod-undefined.mk \
src/usr.bin/make/unit-tests/varmod.mk
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-empty.mk \
src/usr.bin/make/unit-tests/directive-for-if.mk \
src/usr.bin/make/unit-tests/opt-debug-var.mk
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/directive-ifmake.mk \
src/usr.bin/make/unit-tests/varmod-match-escape.mk
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.mk \

CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 21:47:52 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cmdline-undefined.mk comment.mk
cond-cmp-string.mk cond-cmp-unary.mk cond-eof.mk
cond-func-defined.exp cond-func-defined.mk cond-func-empty.mk
cond-func-exists.mk cond-func.mk cond-late.mk cond-short.mk
cond-token-number.mk cond-token-plain.exp cond-token-plain.mk
cond-token-string.exp cond-token-string.mk cond-token-var.mk
dep-var.mk deptgt-makeflags.mk deptgt.mk directive-else.mk
directive-for-empty.mk directive-for-errors.mk
directive-for-escape.mk directive-for-if.mk directive-ifmake.mk
lint.mk opt-debug-file.mk opt-debug-jobs.mk opt-debug-lint.mk
opt-debug-var.mk parse-var.mk sh-dots.mk var-op-assign.mk
var-op-default.mk var-op-expand.mk var-recursive.mk
var-scope-cmdline.mk var-scope-local.mk varmod-assign.mk
varmod-defined.mk varmod-edge.mk varmod-gmtime.mk varmod-ifelse.exp
varmod-ifelse.mk varmod-indirect.mk varmod-l-name-to-value.mk
varmod-localtime.mk varmod-loop-varname.mk varmod-loop.mk
varmod-match-escape.mk varmod-match.mk varmod-range.mk
varmod-subst-regex.mk varmod-sysv.mk varmod-to-separator.mk
varmod-undefined.mk varmod.mk varname-empty.mk varname.mk
varparse-errors.mk varparse-mod.mk varparse-undef-partial.mk

Log Message:
tests/make: replace 'variable expression' with 'expression'

Each expression is based on a variable, there's no need for the
verbosity.  The wording in make's diagnostics will be changed in a
follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline-undefined.mk \
src/usr.bin/make/unit-tests/sh-dots.mk \
src/usr.bin/make/unit-tests/var-op-default.mk \
src/usr.bin/make/unit-tests/var-scope-cmdline.mk \
src/usr.bin/make/unit-tests/varparse-undef-partial.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/comment.mk \
src/usr.bin/make/unit-tests/cond-cmp-unary.mk \
src/usr.bin/make/unit-tests/cond-eof.mk \
src/usr.bin/make/unit-tests/opt-debug-jobs.mk \
src/usr.bin/make/unit-tests/var-recursive.mk \
src/usr.bin/make/unit-tests/varmod-loop-varname.mk
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-cmp-string.mk \
src/usr.bin/make/unit-tests/varmod-edge.mk \
src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-defined.exp \
src/usr.bin/make/unit-tests/cond-token-var.mk \
src/usr.bin/make/unit-tests/deptgt-makeflags.mk \
src/usr.bin/make/unit-tests/var-scope-local.mk \
src/usr.bin/make/unit-tests/varmod-l-name-to-value.mk \
src/usr.bin/make/unit-tests/varmod-subst-regex.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.mk \
src/usr.bin/make/unit-tests/cond-token-string.exp \
src/usr.bin/make/unit-tests/var-op-assign.mk
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-func-empty.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-exists.mk \
src/usr.bin/make/unit-tests/directive-for-errors.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-func.mk \
src/usr.bin/make/unit-tests/varmod-localtime.mk \
src/usr.bin/make/unit-tests/varname.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-late.mk \
src/usr.bin/make/unit-tests/lint.mk
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-short.mk \
src/usr.bin/make/unit-tests/directive-for-escape.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-number.mk \
src/usr.bin/make/unit-tests/opt-debug-file.mk \
src/usr.bin/make/unit-tests/varname-empty.mk \
src/usr.bin/make/unit-tests/varparse-errors.mk
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-token-plain.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/cond-token-plain.mk \
src/usr.bin/make/unit-tests/var-op-expand.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.mk \
src/usr.bin/make/unit-tests/dep-var.mk \
src/usr.bin/make/unit-tests/directive-else.mk \
src/usr.bin/make/unit-tests/parse-var.mk \
src/usr.bin/make/unit-tests/varmod-range.mk \
src/usr.bin/make/unit-tests/varmod-undefined.mk \
src/usr.bin/make/unit-tests/varmod.mk
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-empty.mk \
src/usr.bin/make/unit-tests/directive-for-if.mk \
src/usr.bin/make/unit-tests/opt-debug-var.mk
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/directive-ifmake.mk \
src/usr.bin/make/unit-tests/varmod-match-escape.mk
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.mk \

CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 11:37:44 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk

Log Message:
tests/make: test non-integer fallback in ':mtime' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-mtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4	Sat Aug 19 01:34:21 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.exp	Sun Nov 19 11:37:44 2023
@@ -1,8 +1,10 @@
-make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file1': 
-make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file2': 
-make: "varmod-mtime.mk" line 60: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
-make: "varmod-mtime.mk" line 71: Invalid argument 'errorhandler-no' for modifier ':mtime'
-make: "varmod-mtime.mk" line 71: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
+make: "varmod-mtime.mk" line 47: Unknown modifier "x"
+make: "varmod-mtime.mk" line 47: Malformed conditional (${no/such/file:L:mtime=123x})
+make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file1': 
+make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file2': 
+make: "varmod-mtime.mk" line 70: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
+make: "varmod-mtime.mk" line 81: Invalid argument 'errorhandler-no' for modifier ':mtime'
+make: "varmod-mtime.mk" line 81: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-mtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.6
--- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5	Sat Aug 19 08:19:25 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.mk	Sun Nov 19 11:37:44 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-mtime.mk,v 1.5 2023/08/19 08:19:25 rillig Exp $
+# $NetBSD: varmod-mtime.mk,v 1.6 2023/11/19 11:37:44 rillig Exp $
 #
 # Tests for the ':mtime' variable modifier, which maps each word of the
 # expression to that file's modification time.
@@ -41,6 +41,16 @@ not_found_mtime:=	${no/such/file:L:mtime
 .endif
 
 
+# The fallback timestamp must only be an integer, without trailing characters.
+# expect+2: Unknown modifier "x"
+# expect+1: Malformed conditional (${no/such/file:L:mtime=123x})
+.if ${no/such/file:L:mtime=123x}
+.  error
+.else
+.  error
+.endif
+
+
 # The timestamp of a newly created file must be at least as great as the
 # timestamp when parsing of this makefile started.
 COOKIE=	${TMPDIR:U/tmp}/varmod-mtime.cookie



CVS commit: src/usr.bin/make/unit-tests

2023-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov 19 11:37:44 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk

Log Message:
tests/make: test non-integer fallback in ':mtime' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-11-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 18 19:25:43 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.mk

Log Message:
tests/make: test parsing of the ':?' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-ifelse.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-11-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  2 05:46:26 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-op-append.mk

Log Message:
tests/make: test appending to an environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-op-append.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-op-append.mk
diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.11 src/usr.bin/make/unit-tests/var-op-append.mk:1.12
--- src/usr.bin/make/unit-tests/var-op-append.mk:1.11	Thu Nov  2 05:14:58 2023
+++ src/usr.bin/make/unit-tests/var-op-append.mk	Thu Nov  2 05:46:26 2023
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-append.mk,v 1.11 2023/11/02 05:14:58 rillig Exp $
+# $NetBSD: var-op-append.mk,v 1.12 2023/11/02 05:46:26 rillig Exp $
 #
 # Tests for the '+=' variable assignment operator, which appends to a
 # variable, creating it if necessary.
@@ -56,4 +56,33 @@ VAR.${:U\$\$\$\$\$\$\$\$}+=	dollars
 .  error
 .endif
 
+
+# Appending to an environment variable in the global scope creates a global
+# variable of the same name, taking its initial value from the environment
+# variable.  After the assignment, the environment variable is left as-is,
+# the value of the global variable is not synced back to the environment
+# variable.
+export ENV_PLUS_GLOBAL=from-env-value
+ENV_PLUS_GLOBAL+=	appended-value
+.if ${ENV_PLUS_GLOBAL} != "from-env-value appended-value"
+.  error
+.endif
+EXPORTED!=	echo "$$ENV_PLUS_GLOBAL"
+.if ${EXPORTED} != "from-env-value"
+.  error
+.endif
+
+# Appending to an environment variable in the command line scope ignores the
+# environment variable.
+export ENV_PLUS_COMMAND=from-env-value
+.MAKEFLAGS: ENV_PLUS_COMMAND+=appended-command
+.if ${ENV_PLUS_COMMAND} != "appended-command"
+.  error ${ENV_PLUS_COMMAND}
+.endif
+EXPORTED!=	echo "$$ENV_PLUS_GLOBAL"
+.if ${EXPORTED} != "from-env-value"
+.  error
+.endif
+
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2023-11-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Nov  2 05:46:26 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-op-append.mk

Log Message:
tests/make: test appending to an environment variable


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-op-append.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Oct 19 18:24:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-short.exp cond-short.mk
directive-for.exp directive-for.mk directive-ifndef.mk
directive-include-guard.exp directive-include-guard.mk escape.exp
escape.mk hanoi-include.mk recursive.exp recursive.mk unexport.mk
var-eval-short.mk varmisc.exp varmisc.mk varmod-gmtime.mk

Log Message:
tests/make: clean up, explain and reorganize several tests


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-short.exp \
src/usr.bin/make/unit-tests/directive-include-guard.mk
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.exp \
src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifndef.mk
cvs rdiff -u -r1.11 -r1.12 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/escape.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/escape.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/hanoi-include.mk \
src/usr.bin/make/unit-tests/recursive.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/recursive.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/unexport.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-eval-short.mk
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmisc.exp
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/varmisc.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-short.exp
diff -u src/usr.bin/make/unit-tests/cond-short.exp:1.12 src/usr.bin/make/unit-tests/cond-short.exp:1.13
--- src/usr.bin/make/unit-tests/cond-short.exp:1.12	Sat Mar  4 13:42:36 2023
+++ src/usr.bin/make/unit-tests/cond-short.exp	Thu Oct 19 18:24:33 2023
@@ -7,7 +7,7 @@ expected M pattern
 expected or
 expected or exists
 expected or empty
-make: "cond-short.mk" line 214: Comparison with '<' requires both operands '' and '42' to be numeric
+make: "cond-short.mk" line 231: Comparison with '<' requires both operands '' and '42' to be numeric
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.13
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12	Fri Aug 11 04:56:31 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Thu Oct 19 18:24:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.12 2023/08/11 04:56:31 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.13 2023/10/19 18:24:33 rillig Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -15,8 +15,9 @@
 #	.endif
 #
 # When such a file is included for the second or later time, and the guard
-# variable or the guard target is defined, including the file has no effect,
-# as all its content is skipped.
+# variable or the guard target is defined, the file is skipped completely, as
+# including it would not have any effect, not even on the special variable
+# '.MAKE.MAKEFILES', as that variable skips duplicate pathnames.
 #
 # See also:
 #	https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html
@@ -46,6 +47,25 @@ LINES.variable-ifndef-reuse= \
 # expect: Parse_PushInput: file variable-ifndef-reuse.tmp, line 1
 # expect: Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined
 
+# The guard variable cannot be a number, as numbers are interpreted
+# differently from bare words.
+INCS+=	variable-ifndef-zero
+LINES.variable-ifndef-zero= \
+	'.ifndef 0e0' \
+	'syntax error' \
+	'.endif'
+# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1
+# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1
+
+# The guard variable cannot be a number, as numbers are interpreted
+# differently from bare words.
+INCS+=	variable-ifndef-one
+LINES.variable-ifndef-one= \
+	'.ifndef 1' \
+	'.endif'
+# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1
+# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1
+
 # Comments and empty lines do not affect the multiple-inclusion guard.
 INCS+=	comments
 LINES.comments= \
@@ -124,10 +144,10 @@ LINES.variable-name-exclamation= \
 # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1
 # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1
 
-# A variable name can contain a '!' in the middle, as that character is
-# interpreted as an ordinary character in conditions as well as on the left
-# side of a variable 

CVS commit: src/usr.bin/make/unit-tests

2023-10-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Oct 19 18:24:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-short.exp cond-short.mk
directive-for.exp directive-for.mk directive-ifndef.mk
directive-include-guard.exp directive-include-guard.mk escape.exp
escape.mk hanoi-include.mk recursive.exp recursive.mk unexport.mk
var-eval-short.mk varmisc.exp varmisc.mk varmod-gmtime.mk

Log Message:
tests/make: clean up, explain and reorganize several tests


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-short.exp \
src/usr.bin/make/unit-tests/directive-include-guard.mk
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.exp \
src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifndef.mk
cvs rdiff -u -r1.11 -r1.12 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/escape.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/escape.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/hanoi-include.mk \
src/usr.bin/make/unit-tests/recursive.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/recursive.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/unexport.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-eval-short.mk
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmisc.exp
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/varmisc.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-09-10 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Sep 10 16:25:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: opt-jobs.mk varname-dot-make-jobs.mk

Log Message:
make: skip -jC tests unless .MAKE.JOBS.C is yes


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-jobs.mk \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/opt-jobs.mk
diff -u src/usr.bin/make/unit-tests/opt-jobs.mk:1.4 src/usr.bin/make/unit-tests/opt-jobs.mk:1.5
--- src/usr.bin/make/unit-tests/opt-jobs.mk:1.4	Sun Sep 10 11:41:33 2023
+++ src/usr.bin/make/unit-tests/opt-jobs.mk	Sun Sep 10 16:25:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: opt-jobs.mk,v 1.4 2023/09/10 11:41:33 rillig Exp $
+# $NetBSD: opt-jobs.mk,v 1.5 2023/09/10 16:25:32 sjg Exp $
 #
 # Tests for the -j command line option, which creates the targets in parallel.
 
@@ -39,7 +39,7 @@ EXPECT..5e1C=			# unlikely to o
 EXPECT.07.5C=	
 EXPECT.08.5C=	argument '08.5C' to option '-j' must be a positive number (exit 2)
 
-.if ${.MAKE.JOBS.C}
+.if ${.MAKE.JOBS.C} == "yes"
 .  for arg in ${ARGS}
 OUTPUT!=	${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)"
 .if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric
Index: src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.4 src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.5
--- src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.4	Sat Sep  9 01:30:59 2023
+++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk	Sun Sep 10 16:25:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-make-jobs.mk,v 1.4 2023/09/09 01:30:59 sjg Exp $
+# $NetBSD: varname-dot-make-jobs.mk,v 1.5 2023/09/10 16:25:32 sjg Exp $
 #
 # Tests for the special .MAKE.JOBS variable, which is defined in jobs mode
 # only.  There it contains the number of jobs that may run in parallel.
@@ -15,16 +15,13 @@ all:
 	@${MAKE} -r -f ${MAKEFILE} echo -j20
 	@${MAKE} -r -f ${MAKEFILE} echo -j0001
 
-.if !make(echo)
+.if !make(echo) && ${.MAKE.JOBS.C} == "yes"
 # These results will not be static, we need NCPU
 # to compute expected results.
-# We only support -jC if _SC_NPROCESSORS_ONLN is defined,
-# otherwise we will get NCPU=0
-NCPU!= ${MAKE} -r -f /dev/null -jC -V .MAKE.JOBS 2> /dev/null || echo 0
-
-.if ${NCPU} > 0
 all:	jC
 
+NCPU!= ${MAKE} -r -f /dev/null -jC -V .MAKE.JOBS
+
 # If -j arg is floating point or ends in C;
 # .MAKE.JOBS is a multiple of _SC_NPROCESSORS_ONLN
 # No news is good news here.
@@ -38,7 +35,6 @@ jC:
 	done
 
 .endif
-.endif
 
 # expect: undefined
 # expect: 1



CVS commit: src/usr.bin/make/unit-tests

2023-09-10 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Sep 10 16:25:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: opt-jobs.mk varname-dot-make-jobs.mk

Log Message:
make: skip -jC tests unless .MAKE.JOBS.C is yes


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-jobs.mk \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-09-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 10 11:00:55 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: opt-jobs.mk

Log Message:
tests/make: add tests for parsing the -j option


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-jobs.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/opt-jobs.mk
diff -u src/usr.bin/make/unit-tests/opt-jobs.mk:1.2 src/usr.bin/make/unit-tests/opt-jobs.mk:1.3
--- src/usr.bin/make/unit-tests/opt-jobs.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-jobs.mk	Sun Sep 10 11:00:55 2023
@@ -1,8 +1,51 @@
-# $NetBSD: opt-jobs.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-jobs.mk,v 1.3 2023/09/10 11:00:55 rillig Exp $
 #
-# Tests for the -j command line option.
+# Tests for the -j command line option, which creates the targets in parallel.
 
-# TODO: Implementation
 
-all:
-	@:;
+# The option '-j ' specifies the number of targets that can be made
+# in parallel.
+ARGS=		0 1 2 8 08 0x10 -5 1000
+EXPECT.0=	illegal argument to -j -- must be positive integer! exit 2
+EXPECT.1=	1
+EXPECT.2=	2
+EXPECT.8=	8
+EXPECT.08=	illegal argument to -j -- must be positive integer! exit 2
+EXPECT.0x10=	16
+EXPECT.-5=	illegal argument to -j -- must be positive integer! exit 2
+EXPECT.1000=	1000
+
+.for arg in ${ARGS}
+OUTPUT!=	${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo exit $$?
+.  if ${OUTPUT:[2..-1]} != ${EXPECT.${arg}}
+.  warning ${arg}:${.newline}have: ${OUTPUT:[2..-1]}${.newline}want: ${EXPECT.${arg}}
+.  endif
+.endfor
+
+
+# The options '-j ' and '-j C' multiply the given number with
+# the number of available CPUs.
+ARGS=		0.0 .5 .5C 1C 1CPUs 1.2 .5e1C 07.5C 08.5C
+EXPECT.0.0=	illegal argument to -j -- must be positive integer! exit 2
+EXPECT..5=			# rounded up to 1 if necessary
+EXPECT..5C=			# rounded up to 1 if necessary
+EXPECT.1C=	
+EXPECT.1CPUs=	
+EXPECT.1.2=	
+EXPECT..5e1C=			# unlikely to occur in practice
+EXPECT.07.5C=	
+EXPECT.08.5C=	illegal argument to -j -- must be positive integer! exit 2
+
+.if ${.MAKE.JOBS.C}
+.  for arg in ${ARGS}
+OUTPUT!=	${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo exit $$?
+.if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric
+OUTPUT=		
+.endif
+.if ${OUTPUT:[2..-1]} != ${EXPECT.${arg}}
+.  warning ${arg}:${.newline}have: ${OUTPUT:[2..-1]}${.newline}want: ${EXPECT.${arg}}
+.endif
+.  endfor
+.endif
+
+all: .PHONY



CVS commit: src/usr.bin/make/unit-tests

2023-09-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 10 11:00:55 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: opt-jobs.mk

Log Message:
tests/make: add tests for parsing the -j option


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-jobs.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  7 05:36:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.mk
cond-cmp-numeric-ge.mk cond-cmp-numeric-gt.mk
cond-cmp-numeric-le.mk cond-cmp-numeric-lt.mk
cond-cmp-numeric-ne.mk

Log Message:
tests/make: fix test for conditions of the form 'a > b'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-lt.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-ne.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.7
--- src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk:1.6	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk	Thu Sep  7 05:36:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric-eq.mk,v 1.6 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: cond-cmp-numeric-eq.mk,v 1.7 2023/09/07 05:36:33 rillig Exp $
 #
 # Tests for numeric comparisons with the == operator in .if conditions.
 
@@ -40,7 +40,7 @@
 .  error
 .endif
 
-# As of 2020-08-23, numeric comparison is implemented as parsing both sides
+# Numeric comparison works by parsing both sides
 # as double, and then performing a normal comparison.  The range of double is
 # typically 16 or 17 significant digits, therefore these two numbers seem to
 # be equal.
@@ -78,6 +78,3 @@
 .else
 .  error
 .endif
-
-all:
-	@:;

Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk:1.3
--- src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk:1.2	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk	Thu Sep  7 05:36:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric-ge.mk,v 1.2 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-cmp-numeric-ge.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
 #
 # Tests for numeric comparisons with the >= operator in .if conditions.
 
@@ -62,7 +62,7 @@
 .  error
 .endif
 
-# As of 2020-08-23, numeric comparison is implemented as parsing both sides
+# Numeric comparison works by parsing both sides
 # as double, and then performing a normal comparison.  The range of double is
 # typically 16 or 17 significant digits, therefore these two numbers seem to
 # be equal.
Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk:1.3
--- src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk:1.2	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk	Thu Sep  7 05:36:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric-gt.mk,v 1.2 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-cmp-numeric-gt.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
 #
 # Tests for numeric comparisons with the > operator in .if conditions.
 
@@ -61,11 +61,11 @@
 .  error
 .endif
 
-# As of 2020-08-23, numeric comparison is implemented as parsing both sides
+# Numeric comparison works by parsing both sides
 # as double, and then performing a normal comparison.  The range of double is
 # typically 16 or 17 significant digits, therefore these two numbers seem to
 # be equal.
-.if 1.01 > 1.02
+.if 1.02 > 1.01
 .  error
 .endif
 
Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk:1.3
--- src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk:1.2	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk	Thu Sep  7 05:36:33 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-cmp-numeric-le.mk,v 1.2 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: cond-cmp-numeric-le.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
 #
 # Tests for numeric comparisons with the <= operator in .if conditions.
 
@@ -62,7 +62,7 @@
 .  error
 .endif
 
-# As of 2020-08-23, numeric comparison is implemented as parsing both sides
+# Numeric comparison works by parsing both sides
 # as double, and then performing a normal comparison.  The range of double is
 # typically 16 or 17 significant digits, therefore these two numbers seem to
 # be equal.
Index: src/usr.bin/make/unit-tests/cond-cmp-numeric-lt.mk
diff -u src/usr.bin/make/unit-tests/cond-cmp-numeric-lt.mk:1.2 src/usr.bin/make/unit-tests/cond-cmp-numeric-lt.mk:1.3
--- 

CVS commit: src/usr.bin/make/unit-tests

2023-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  7 05:36:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.mk
cond-cmp-numeric-ge.mk cond-cmp-numeric-gt.mk
cond-cmp-numeric-le.mk cond-cmp-numeric-lt.mk
cond-cmp-numeric-ne.mk

Log Message:
tests/make: fix test for conditions of the form 'a > b'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-lt.mk \
src/usr.bin/make/unit-tests/cond-cmp-numeric-ne.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 20 20:48:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-export-gmake.exp
directive-export-gmake.mk directive-export.exp directive-export.mk

Log Message:
tests/make: show a difference between 'export' and '.export'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/directive-export-gmake.exp \
src/usr.bin/make/unit-tests/directive-export.exp
cvs rdiff -u -r1.6 -r1.7 \
src/usr.bin/make/unit-tests/directive-export-gmake.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-export.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-export-gmake.exp
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.4 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.5
--- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.4	Sat Aug 19 11:09:02 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.exp	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,5 @@
 make: "directive-export-gmake.mk" line 71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1'
+make: "directive-export-gmake.mk" line 85: 16:00:00
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/directive-export.exp
diff -u src/usr.bin/make/unit-tests/directive-export.exp:1.4 src/usr.bin/make/unit-tests/directive-export.exp:1.5
--- src/usr.bin/make/unit-tests/directive-export.exp:1.4	Sun Dec 13 01:07:54 2020
+++ src/usr.bin/make/unit-tests/directive-export.exp	Sun Aug 20 20:48:32 2023
@@ -1 +1,4 @@
+make: "directive-export.mk" line 50: 00:00:00
+make: "directive-export.mk" line 55: 00:00:00
+make: "directive-export.mk" line 58: 16:00:00
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-export-gmake.mk
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.6 src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.7
--- src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.6	Sat Aug 19 11:09:02 2023
+++ src/usr.bin/make/unit-tests/directive-export-gmake.mk	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export-gmake.mk,v 1.6 2023/08/19 11:09:02 rillig Exp $
+# $NetBSD: directive-export-gmake.mk,v 1.7 2023/08/20 20:48:32 rillig Exp $
 #
 # Tests for the export directive (without leading dot), as in GNU make.
 
@@ -70,3 +70,16 @@ export VAR=an ${UNDEF} variable
 # expect+1: Invalid line 'export VAR=${:U1}'
 export VAR=${value}
 .endfor
+
+
+# The 'export' directive expands expressions, but the expressions must not
+# contain a ':', due to the overly strict parser.  The indirect expressions
+# may contain a ':', though.
+#
+# As a side effect, this test demonstrates that the 'export' directive exports
+# the environment variable immediately, other than the '.export' directive,
+# which defers that action if the variable value contains a '$'.
+INDIRECT_TZ=	${:UAmerica/Los_Angeles}
+export TZ=${INDIRECT_TZ}
+# expect+1: 16:00:00
+.info ${%T:L:localtime=86400}

Index: src/usr.bin/make/unit-tests/directive-export.mk
diff -u src/usr.bin/make/unit-tests/directive-export.mk:1.8 src/usr.bin/make/unit-tests/directive-export.mk:1.9
--- src/usr.bin/make/unit-tests/directive-export.mk:1.8	Tue Feb 16 19:01:18 2021
+++ src/usr.bin/make/unit-tests/directive-export.mk	Sun Aug 20 20:48:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export.mk,v 1.8 2021/02/16 19:01:18 rillig Exp $
+# $NetBSD: directive-export.mk,v 1.9 2023/08/20 20:48:32 rillig Exp $
 #
 # Tests for the .export directive.
 #
@@ -41,4 +41,21 @@ EMPTY_SHELL=	${:sh}
 _!=		:;:	# Force the variable to be actually exported.
 
 
+# If the '.export' directive exports a variable whose value contains a '$',
+# the actual export action is deferred until a subprocess is started, assuming
+# that only subprocesses access the environment variables.  The ':localtime'
+# modifier depends on the 'TZ' environment variable, without any subprocess.
+export TZ=${UTC}
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+INDIRECT_TZ=	${:UAmerica/Los_Angeles}
+TZ=		${INDIRECT_TZ}
+.export TZ
+# expect+1: 00:00:00
+.info ${%T:L:localtime=86400}
+_!=	echo 'force exporting the environment variables'
+# expect+1: 16:00:00
+.info ${%T:L:localtime=86400}
+
+
 all:



CVS commit: src/usr.bin/make/unit-tests

2023-08-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 20 20:48:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-export-gmake.exp
directive-export-gmake.mk directive-export.exp directive-export.mk

Log Message:
tests/make: show a difference between 'export' and '.export'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/directive-export-gmake.exp \
src/usr.bin/make/unit-tests/directive-export.exp
cvs rdiff -u -r1.6 -r1.7 \
src/usr.bin/make/unit-tests/directive-export-gmake.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-export.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 19 10:33:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-export-gmake.exp
directive-export-gmake.mk varmod-gmtime.mk

Log Message:
tests/make: provide instructions for reproducing bug in gmtime

The test is not enabled because its results differ too much between the
platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/directive-export-gmake.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/directive-export-gmake.mk
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-gmtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-export-gmake.exp
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.1 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.2
--- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.1	Fri Oct  2 20:34:59 2020
+++ src/usr.bin/make/unit-tests/directive-export-gmake.exp	Sat Aug 19 10:33:32 2023
@@ -1 +1,4 @@
-exit status 0
+make: "directive-export-gmake.mk" line 74: Invalid line type
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-export-gmake.mk
diff -u src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.3 src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.4
--- src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.3	Tue Nov 17 20:16:44 2020
+++ src/usr.bin/make/unit-tests/directive-export-gmake.mk	Sat Aug 19 10:33:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-export-gmake.mk,v 1.3 2020/11/17 20:16:44 rillig Exp $
+# $NetBSD: directive-export-gmake.mk,v 1.4 2023/08/19 10:33:32 rillig Exp $
 #
 # Tests for the export directive (without leading dot), as in GNU make.
 
@@ -60,5 +60,16 @@ export VAR=an ${UNDEF} variable
 .  error
 .endif
 
-all:
-	@:;
+
+# The body of the .for loop expands to 'export VAR=${:U1}', and the 'export'
+# directive is only recognized if the line does not contain a ':', to allow
+# 'export' to be a regular target.
+.for value in 1
+# FIXME: The below error message is missing all details.  But even if it
+# contained the text of the line, it would be confusing because at the point
+# where that error message is printed, all expressions from the line have
+# already been expanded as part of the dependency line parsing, which in this
+# case hides the ':' from the error message.
+# expect+1: Invalid line type
+export VAR=${value}
+.endfor

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.16 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.17
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.16	Sat Aug 19 08:19:25 2023
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Sat Aug 19 10:33:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.16 2023/08/19 08:19:25 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.17 2023/08/19 10:33:32 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -194,5 +194,33 @@
 #	* ':gmtime' reports the correct timezone offset '+'.
 #	* ':gmtime' reports different seconds since the Epoch, and the '%s'
 #	  value cannot be derived from the '%F %T %z' values.
+.if 0			# only for reference, due to platform differences
+export TZ=UTC
+.  for t in ${%s:L:gmtime} ${%s:L:localtime}
+TIMESTAMPS+= $t
+.  endfor
+export TZ=Europe/Berlin
+.  for t in ${%s:L:gmtime} ${%s:L:localtime}
+TIMESTAMPS+= $t
+.  endfor
+export TZ=UTC
+.  for t in ${%s:L:gmtime} ${%s:L:localtime}
+TIMESTAMPS+= $t
+.  endfor
+export TZ=America/Los_Angeles
+.  for t in ${%s:L:gmtime} ${%s:L:localtime}
+TIMESTAMPS+= $t
+.  endfor
+export TZ=UTC
+.  for t in ${%s:L:gmtime} ${%s:L:localtime}
+TIMESTAMPS+= $t
+.  endfor
+.  info ${TIMESTAMPS:u}
+.  for a b in ${TIMESTAMPS:[1]} ${TIMESTAMPS:@t@$t $t@} ${TIMESTAMPS:[-1]}
+.if $a > $b
+.  warning timestamp $a > $b
+.endif
+.  endfor
+.endif
 
 all:



CVS commit: src/usr.bin/make/unit-tests

2023-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 19 10:33:32 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-export-gmake.exp
directive-export-gmake.mk varmod-gmtime.mk

Log Message:
tests/make: provide instructions for reproducing bug in gmtime

The test is not enabled because its results differ too much between the
platforms.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/directive-export-gmake.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/directive-export-gmake.mk
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-gmtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 19 08:19:25 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-gmtime.mk varmod-mtime.mk

Log Message:
tests/make: document bug in ':gmtime' with '%s'


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.15 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.16
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.15	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Sat Aug 19 08:19:25 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.15 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.16 2023/08/19 08:19:25 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3) in UTC.
@@ -145,4 +145,54 @@
 .  error
 .endif
 
+
+# As of 2023-08-19, ':gmtime' but not ':localtime' reports wrong values for
+# '%s', depending on the operating system and the timezone, as demonstrated by
+# the following test program:
+#
+#	for mod in gmtime localtime; do
+#		for tz in UTC Europe/Berlin America/Los_Angeles; do
+#			TZ=$tz bmake -r -v "\${%F %T %z %s $mod $tz:L:$mod}"
+#		done
+#	done
+#
+# Cygwin:
+# 2023-08-19 07:34:06 + 1692430446 gmtime UTC
+# 2023-08-19 07:34:06 + 1692430446 gmtime Europe/Berlin
+# 2023-08-19 07:34:06 + 1692430446 gmtime America/Los_Angeles
+# 2023-08-19 07:34:06 + 1692430446 localtime UTC
+# 2023-08-19 09:34:07 +0200 1692430447 localtime Europe/Berlin
+# 2023-08-19 00:34:07 -0700 1692430447 localtime America/Los_Angeles
+#
+# Looks good:
+#	* ':gmtime' consistently reports timezone offset '+'.
+#	* '%s' is independent of the timezone.
+#
+# NetBSD 10.99:
+# 2023-08-19 07:34:37 + 1692430477 gmtime UTC
+# 2023-08-19 07:34:37 +0100 1692426877 gmtime Europe/Berlin
+# 2023-08-19 07:34:37 -0800 1692459277 gmtime America/Los_Angeles
+# 2023-08-19 07:34:37 + 1692430477 localtime UTC
+# 2023-08-19 09:34:37 +0200 1692430477 localtime Europe/Berlin
+# 2023-08-19 00:34:37 -0700 1692430477 localtime America/Los_Angeles
+#
+# Looks bad:
+#	* ':gmtime' reports different timezone offsets.
+#	* ':gmtime' reports different seconds since the Epoch.
+#	* ':gmtime' reports the timezone offset '+0100' for Europe/Berlin,
+#	  even though at 2023-08-19, DST with offset '+0200' was in place.
+#
+# Debian:
+# 2023-08-19 07:29:10 + 1692430150 gmtime UTC
+# 2023-08-19 07:29:10 + 1692426550 gmtime Europe/Berlin
+# 2023-08-19 07:29:10 + 1692458950 gmtime America/Los_Angeles
+# 2023-08-19 07:29:10 + 1692430150 localtime UTC
+# 2023-08-19 09:29:10 +0200 1692430150 localtime Europe/Berlin
+# 2023-08-19 00:29:10 -0700 1692430150 localtime America/Los_Angeles
+#
+# Looks mixed:
+#	* ':gmtime' reports the correct timezone offset '+'.
+#	* ':gmtime' reports different seconds since the Epoch, and the '%s'
+#	  value cannot be derived from the '%F %T %z' values.
+
 all:

Index: src/usr.bin/make/unit-tests/varmod-mtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4	Sat Aug 19 01:34:21 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.mk	Sat Aug 19 08:19:25 2023
@@ -1,11 +1,11 @@
-# $NetBSD: varmod-mtime.mk,v 1.4 2023/08/19 01:34:21 sjg Exp $
+# $NetBSD: varmod-mtime.mk,v 1.5 2023/08/19 08:19:25 rillig Exp $
 #
 # Tests for the ':mtime' variable modifier, which maps each word of the
 # expression to that file's modification time.
 
 # Note: strftime() uses mktime() for %s and mktime() assumes localtime
 # so this should match time()
-start:=	${%s:L:localtime}
+start:=	${%s:L:localtime}	# see varmod-gmtime.mk, keyword '%s'
 
 
 # Ensure that this makefile exists and has a modification time.  If the file



CVS commit: src/usr.bin/make/unit-tests

2023-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 19 08:19:25 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-gmtime.mk varmod-mtime.mk

Log Message:
tests/make: document bug in ':gmtime' with '%s'


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 19 01:34:21 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk

Log Message:
varmod-mtime.mk: use :localtime for %s

Add a comment to explain why ${%s:L:localtime} should be used to get
a value that matches time(3).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp \
src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 19 01:34:21 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk

Log Message:
varmod-mtime.mk: use :localtime for %s

Add a comment to explain why ${%s:L:localtime} should be used to get
a value that matches time(3).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp \
src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-mtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.3 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.3	Thu Aug 17 19:06:51 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.exp	Sat Aug 19 01:34:21 2023
@@ -1,8 +1,8 @@
-make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file1': 
-make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file2': 
-make: "varmod-mtime.mk" line 58: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
-make: "varmod-mtime.mk" line 69: Invalid argument 'errorhandler-no' for modifier ':mtime'
-make: "varmod-mtime.mk" line 69: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
+make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file1': 
+make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file2': 
+make: "varmod-mtime.mk" line 60: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
+make: "varmod-mtime.mk" line 71: Invalid argument 'errorhandler-no' for modifier ':mtime'
+make: "varmod-mtime.mk" line 71: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/varmod-mtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.3 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.3	Thu Aug 17 19:06:51 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.mk	Sat Aug 19 01:34:21 2023
@@ -1,9 +1,11 @@
-# $NetBSD: varmod-mtime.mk,v 1.3 2023/08/17 19:06:51 rillig Exp $
+# $NetBSD: varmod-mtime.mk,v 1.4 2023/08/19 01:34:21 sjg Exp $
 #
 # Tests for the ':mtime' variable modifier, which maps each word of the
 # expression to that file's modification time.
 
-start:=	${%s:L:gmtime}
+# Note: strftime() uses mktime() for %s and mktime() assumes localtime
+# so this should match time()
+start:=	${%s:L:localtime}
 
 
 # Ensure that this makefile exists and has a modification time.  If the file



CVS commit: src/usr.bin/make/unit-tests

2023-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 17 18:48:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-mtime.exp varmod-mtime.mk

Log Message:
tests/make: extend tests for the ':mtime' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-mtime.exp \
src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.339 src/usr.bin/make/unit-tests/Makefile:1.340
--- src/usr.bin/make/unit-tests/Makefile:1.339	Tue Jun 20 09:25:34 2023
+++ src/usr.bin/make/unit-tests/Makefile	Thu Aug 17 18:48:32 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.339 2023/06/20 09:25:34 rillig Exp $
+# $NetBSD: Makefile,v 1.340 2023/08/17 18:48:32 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -559,6 +559,7 @@ SED_CMDS.suff-transform-debug+=	${STD_SE
 SED_CMDS.var-op-shell+=		${STD_SED_CMDS.shell}
 SED_CMDS.var-op-shell+=		-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=		-e 's,${.SHELL},,'
+SED_CMDS.varmod-mtime+=		-e "s,': .*,': ,"
 SED_CMDS.varmod-subst-regex+=	${STD_SED_CMDS.regex}
 SED_CMDS.varparse-errors+=	${STD_SED_CMDS.timestamp}
 SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore}

Index: src/usr.bin/make/unit-tests/varmod-mtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.1 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.1	Tue May  9 20:14:27 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.exp	Thu Aug 17 18:48:32 2023
@@ -1 +1,8 @@
-exit status 0
+make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file1': 
+make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file2': 
+make: "varmod-mtime.mk" line 58: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
+make: "varmod-mtime.mk" line 69: Unknown modifier "handler-no"
+make: "varmod-mtime.mk" line 69: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0)
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/varmod-mtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.1 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.1	Tue May  9 20:14:27 2023
+++ src/usr.bin/make/unit-tests/varmod-mtime.mk	Thu Aug 17 18:48:32 2023
@@ -1,30 +1,80 @@
-# $NetBSD: varmod-mtime.mk,v 1.1 2023/05/09 20:14:27 sjg Exp $
+# $NetBSD: varmod-mtime.mk,v 1.2 2023/08/17 18:48:32 rillig Exp $
 #
-# Tests for the :mtime variable modifier, which provides mtime
-# of variable value assumed to be a pathname.
+# Tests for the ':mtime' variable modifier, which maps each word of the
+# expression to that file's modification time.
 
-all:
+start:=	${%s:L:gmtime}
 
-# mtime of this makefile
-mtime:= ${MAKEFILE:mtime}
 
-# if pathname does not exist and timestamp is provided
-# that is the result
-.if ${no/such:L:mtime=0} != "0"
+# Ensure that this makefile exists and has a modification time.  If the file
+# didn't exist, the ':mtime' modifier would return the current time.
+.if ${MAKEFILE:mtime} >= ${start}
 .  error
 .endif
 
-.if ${no/such:L:mtime=42} != "42"
+
+# For a file that doesn't exist, the ':mtime' modifier returns the current
+# time, without an error or warning message.  The returned timestamp differs
+# from the 'now' that is used when updating the timestamps in archives or for
+# touching files using the '-t' option, which is taken once when make is
+# started.
+not_found_mtime:=	${no/such/file:L:mtime}
+.if ${not_found_mtime} < ${start}
+.  error
+.endif
+
+
+# The ':mtime' modifier accepts a timestamp in seconds as an optional
+# argument.  This timestamp is used as a fallback in case the file's time
+# cannot be determined, without any error or warning message.
+.if ${no/such/file:L:mtime=0} != "0"
+.  error
+.endif
+
+
+# The fallback timestamp must start with a digit, and it is interpreted as a
+# decimal integer.
+.if ${no/such/file:L:mtime=00042} != "42"
+.  error
+.endif
+
+
+# The timestamp of a newly created file must be at least as great as the
+# timestamp when parsing of this makefile started.
+COOKIE=	${TMPDIR:U/tmp}/varmod-mtime.cookie
+_!=	touch ${COOKIE}
+.if ${COOKIE:mtime=0} < ${start}
+.   error ${COOKIE:mtime=0} < ${start}
+.endif
+_!=	rm -f ${COOKIE}
+
+
+# If the optional argument of the ':mtime' modifier is the word 'error', the
+# modifier fails with an error message, once for each affected file.
+#
+# expect+3: Cannot determine mtime for 'no/such/file1': 
+# expect+2: Cannot determine mtime for 'no/such/file2': 
+# expect+1: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error})
+.if ${no/such/file1 

CVS commit: src/usr.bin/make/unit-tests

2023-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 17 18:48:33 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: Makefile varmod-mtime.exp varmod-mtime.mk

Log Message:
tests/make: extend tests for the ':mtime' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-mtime.exp \
src/usr.bin/make/unit-tests/varmod-mtime.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 15 21:27:09 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-op-and.mk cond-op-or.mk

Log Message:
tests/make: show that '||' and '&&' must be preceded by whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-op-and.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-op-or.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-op-and.mk
diff -u src/usr.bin/make/unit-tests/cond-op-and.mk:1.7 src/usr.bin/make/unit-tests/cond-op-and.mk:1.8
--- src/usr.bin/make/unit-tests/cond-op-and.mk:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/cond-op-and.mk	Tue Aug 15 21:27:09 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-and.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: cond-op-and.mk,v 1.8 2023/08/15 21:27:09 rillig Exp $
 #
 # Tests for the && operator in .if conditions.
 
@@ -76,5 +76,9 @@ DEF=	defined
 .  error
 .endif
 
-all:
-	@:;
+# The '&&' operator must be preceded by whitespace, otherwise it becomes part
+# of the preceding bare word.  The condition is parsed as '"1&&" != "" && 1'.
+.if 1&& && 1
+.else
+.  error
+.endif

Index: src/usr.bin/make/unit-tests/cond-op-or.mk
diff -u src/usr.bin/make/unit-tests/cond-op-or.mk:1.9 src/usr.bin/make/unit-tests/cond-op-or.mk:1.10
--- src/usr.bin/make/unit-tests/cond-op-or.mk:1.9	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/cond-op-or.mk	Tue Aug 15 21:27:09 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op-or.mk,v 1.9 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: cond-op-or.mk,v 1.10 2023/08/15 21:27:09 rillig Exp $
 #
 # Tests for the || operator in .if conditions.
 
@@ -76,5 +76,9 @@ DEF=	defined
 .  error
 .endif
 
-all:
-	@:;
+# The '||' operator must be preceded by whitespace, otherwise it becomes part
+# of the preceding bare word.  The condition is parsed as '"1||" != "" || 0'.
+.if 1|| || 0
+.else
+.  error
+.endif



CVS commit: src/usr.bin/make/unit-tests

2023-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 15 21:27:09 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-op-and.mk cond-op-or.mk

Log Message:
tests/make: show that '||' and '&&' must be preceded by whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-op-and.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-op-or.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Aug 11 05:01:12 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.mk

Log Message:
tests/make: fix grammar in a test comment


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-func-empty.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Aug 11 05:01:12 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.mk

Log Message:
tests/make: fix grammar in a test comment


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-func-empty.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-func-empty.mk
diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.21 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.22
--- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.21	Wed Jun 28 06:15:42 2023
+++ src/usr.bin/make/unit-tests/cond-func-empty.mk	Fri Aug 11 05:01:12 2023
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-empty.mk,v 1.21 2023/06/28 06:15:42 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.22 2023/08/11 05:01:12 rillig Exp $
 #
 # Tests for the empty() function in .if conditions, which tests a variable
 # expression for emptiness.
@@ -150,7 +150,7 @@ ${:U }=	space
 .  error
 .endif
 
-# There may be spaces at the outside the parentheses.
+# There may be spaces outside the parentheses.
 # Spaces inside the parentheses are interpreted as part of the variable name.
 .if ! empty ( WORD )
 .  error



CVS commit: src/usr.bin/make/unit-tests

2023-07-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul  1 09:06:34 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: show how to use indirect conditions in the '?:' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-ifelse.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 28 06:15:42 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.exp cond-func-empty.mk

Log Message:
tests/make: extend test for the 'empty' function in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-empty.exp
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-func-empty.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/cond-func-empty.exp
diff -u src/usr.bin/make/unit-tests/cond-func-empty.exp:1.6 src/usr.bin/make/unit-tests/cond-func-empty.exp:1.7
--- src/usr.bin/make/unit-tests/cond-func-empty.exp:1.6	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/cond-func-empty.exp	Wed Jun 28 06:15:42 2023
@@ -1,5 +1,5 @@
-make: "cond-func-empty.mk" line 154: Unclosed variable "WORD"
-make: "cond-func-empty.mk" line 154: Malformed conditional (empty(WORD)
+make: "cond-func-empty.mk" line 168: Unclosed variable "WORD"
+make: "cond-func-empty.mk" line 168: Malformed conditional (empty(WORD)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-func-empty.mk
diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.20 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.21
--- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.20	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/cond-func-empty.mk	Wed Jun 28 06:15:42 2023
@@ -1,18 +1,19 @@
-# $NetBSD: cond-func-empty.mk,v 1.20 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.21 2023/06/28 06:15:42 rillig Exp $
 #
 # Tests for the empty() function in .if conditions, which tests a variable
 # expression for emptiness.
 #
 # Note that the argument in the parentheses is a variable name, not a variable
-# expression, optionally followed by variable modifiers.
+# expression.  That name may be followed by ':...' modifiers.
 #
 
 .undef UNDEF
 EMPTY=	# empty
 SPACE=	${:U }
+ZERO=	0
 WORD=	word
 
-# An undefined variable is empty.
+# An undefined variable counts as empty.
 .if !empty(UNDEF)
 .  error
 .endif
@@ -78,6 +79,17 @@ WORD=	word
 .  error
 .endif
 
+# The variable ZERO has the numeric value 0, but is not empty.  This is a
+# subtle difference between using either 'empty(ZERO)' or the expression
+# '${ZERO}' in a condition.
+.if empty(ZERO)
+.  error
+.elif ${ZERO}
+.  error
+.elif ${ZERO} == ""
+.  error
+.endif
+
 # The following example constructs an expression with the variable name ""
 # and the value " ".  This expression counts as empty since the value contains
 # only whitespace.
@@ -101,7 +113,9 @@ ${:U }=	space
 .  error
 .endif
 
-# The value of the following expression is " word", which is not empty.
+# The value of the following expression is " word", which is not empty.  To be
+# empty, _all_ characters in the expression value have to be whitespace, not
+# only the first.
 .if empty(:U word)
 .  error
 .endif
@@ -128,15 +142,15 @@ ${:U }=	space
 # argument are properly parsed.  Typical use cases for this are .for loops,
 # which are expanded to exactly these ${:U} expressions.
 #
-# If everything goes well, the argument expands to "WORD", and that variable
-# is defined at the beginning of this file.  The surrounding 'W' and 'D'
-# ensure that CondParser_FuncCallEmpty keeps track of the parsing position,
-# both before and after the call to Var_Parse.
+# The argument expands to "WORD", and that variable is defined at the
+# beginning of this file.  The surrounding 'W' and 'D' ensure that
+# CondParser_FuncCallEmpty keeps track of the parsing position, both before
+# and after the call to Var_Parse.
 .if empty(W${:UOR}D)
 .  error
 .endif
 
-# There may be spaces at the outside of the parentheses.
+# There may be spaces at the outside the parentheses.
 # Spaces inside the parentheses are interpreted as part of the variable name.
 .if ! empty ( WORD )
 .  error
@@ -181,8 +195,8 @@ ${:U WORD }=	variable name with spaces
 # prevent it from doing any harm.
 #
 # The variable expression was expanded though, and this was wrong.  The
-# expansion was done without VARE_WANTRES (called VARF_WANTRES back
-# then) though.  This had the effect that the ${:U1} from the value of VARNAME
+# expansion was done without VARE_WANTRES (called VARF_WANTRES back then)
+# though.  This had the effect that the ${:U1} from the value of VARNAME
 # expanded to an empty string.  This in turn created the seemingly recursive
 # definition VARNAME=${VARNAME}, and that definition was never meant to be
 # expanded.



CVS commit: src/usr.bin/make/unit-tests

2023-06-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 28 06:15:42 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.exp cond-func-empty.mk

Log Message:
tests/make: extend test for the 'empty' function in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-empty.exp
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-func-empty.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 23 06:11:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: explain and extend tests for expansion in .for loops


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.20 -r1.21 \
src/usr.bin/make/unit-tests/directive-for-escape.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.21 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.22
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.21	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Fri Jun 23 06:11:06 2023
@@ -25,6 +25,22 @@ For: loop body with i = $(V:=-with-modif
 .  info ${:U$(V:=-with-modifier)}
 make: "directive-for-escape.mk" line 45: value-with-modifier
 For: end for 1
+For: loop body with i = $:
+.  info ${:U\$}
+make: "directive-for-escape.mk" line 60: $
+For: loop body with i = ${V}:
+.  info ${:U${V}}
+make: "directive-for-escape.mk" line 60: value
+For: loop body with i = ${V:=-with-modifier}:
+.  info ${:U${V:=-with-modifier}}
+make: "directive-for-escape.mk" line 60: value-with-modifier
+For: loop body with i = $(V):
+.  info ${:U$(V)}
+make: "directive-for-escape.mk" line 60: value
+For: loop body with i = $(V:=-with-modifier):
+.  info ${:U$(V:=-with-modifier)}
+make: "directive-for-escape.mk" line 60: value-with-modifier
+For: end for 1
 For: loop body with i = ${UNDEF:U\$\$:
 # ${:U\${UNDEF\:U\\$\\$}
 For: loop body with i = {{}}:
@@ -34,24 +50,24 @@ For: loop body with i = end}:
 For: end for 1
 For: loop body with i = ${UNDEF:U\$\$:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 99: ${UNDEF:U\backslash$
+make: "directive-for-escape.mk" line 115: ${UNDEF:U\backslash$
 For: loop body with i = {{}}:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 99: {{}}
+make: "directive-for-escape.mk" line 115: {{}}
 For: loop body with i = end}:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 99: end}
+make: "directive-for-escape.mk" line 115: end}
 For: end for 1
 For: loop body with i = begin<${UNDEF:Ufallback:N{{{>end:
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
-make: "directive-for-escape.mk" line 120: beginend
+make: "directive-for-escape.mk" line 136: beginend
 For: end for 1
 For: loop body with i = $:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 129: $
-make: "directive-for-escape.mk" line 138: invalid character ':' in .for loop variable name
+make: "directive-for-escape.mk" line 145: $
+make: "directive-for-escape.mk" line 154: invalid character ':' in .for loop variable name
 For: end for 1
-make: "directive-for-escape.mk" line 148: invalid character '}' in .for loop variable name
+make: "directive-for-escape.mk" line 164: invalid character '}' in .for loop variable name
 For: end for 1
 For: end for 1
 For: loop body with i = inner:
@@ -65,45 +81,45 @@ For: loop body with i = inner:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 157: .$i: inner
-make: "directive-for-escape.mk" line 158: .  ${i}: inner
-make: "directive-for-escape.mk" line 159: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 160: .  $(i): inner
-make: "directive-for-escape.mk" line 161: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 162: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 163: .${i\}}: inner}
-make: "directive-for-escape.mk" line 164: . ${i2}: two
-make: "directive-for-escape.mk" line 165: . ${i,}: comma
-make: "directive-for-escape.mk" line 166: .  adjacent: innerinnerinnerinner
-make: "directive-for-escape.mk" line 185: invalid character '$' in .for loop variable name
+make: "directive-for-escape.mk" line 173: .$i: inner
+make: "directive-for-escape.mk" line 174: .  ${i}: inner
+make: "directive-for-escape.mk" line 175: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 176: .  $(i): inner
+make: "directive-for-escape.mk" line 177: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 178: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 179: .${i\}}: inner}
+make: "directive-for-escape.mk" line 180: . ${i2}: two
+make: "directive-for-escape.mk" line 181: . ${i,}: comma
+make: "directive-for-escape.mk" line 182: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 201: invalid character '$' in .for loop variable name
 For: end for 1
-make: "directive-for-escape.mk" line 197: eight  and no cents.
+make: "directive-for-escape.mk" line 213: eight  and no cents.
 

CVS commit: src/usr.bin/make/unit-tests

2023-06-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 23 06:11:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
tests/make: explain and extend tests for expansion in .for loops


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.20 -r1.21 \
src/usr.bin/make/unit-tests/directive-for-escape.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 23 04:41:24 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: check-expect.lua

Log Message:
tests/make: sort missing 'expect' comments by their location


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/check-expect.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 23 04:41:24 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: check-expect.lua

Log Message:
tests/make: sort missing 'expect' comments by their location


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/check-expect.lua

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/check-expect.lua
diff -u src/usr.bin/make/unit-tests/check-expect.lua:1.6 src/usr.bin/make/unit-tests/check-expect.lua:1.7
--- src/usr.bin/make/unit-tests/check-expect.lua:1.6	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/check-expect.lua	Fri Jun 23 04:41:24 2023
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.6 2023/06/01 20:56:35 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.7 2023/06/23 04:41:24 rillig Exp $
 
 --[[
 
@@ -68,6 +68,33 @@ local function collect_lineno_diagnostic
 end
 
 
+local function missing(by_location)
+  ---@type {filename: string, lineno: number, location: string, message: string}[]
+  local missing_expectations = {}
+
+  for location, messages in pairs(by_location) do
+for _, message in ipairs(messages) do
+  if message ~= "" and location:find(".mk:") then
+local filename, lineno = location:match("^(%S+):(%d+)$")
+table.insert(missing_expectations, {
+  filename = filename,
+  lineno = tonumber(lineno),
+  location = location,
+  message = message
+})
+  end
+end
+  end
+  table.sort(missing_expectations, function(a, b)
+if a.filename ~= b.filename then
+  return a.filename < b.filename
+end
+return a.lineno < b.lineno
+  end)
+  return missing_expectations
+end
+
+
 local function check_mk(mk_fname)
   local exp_fname = mk_fname:gsub("%.mk$", ".exp")
   local mk_lines = load_lines(mk_fname)
@@ -119,13 +146,8 @@ local function check_mk(mk_fname)
 end
   end
 
-  -- XXX: The messages are not sorted in any meaningful way.
-  for location, messages in pairs(by_location) do
-for _, message in ipairs(messages) do
-  if message ~= "" and location:find(".mk:") then
-print_error("missing: %s: # expect+1: %s", location, message)
-  end
-end
+  for _, m in ipairs(missing(by_location)) do
+print_error("missing: %s: # expect+1: %s", m.location, m.message)
   end
 end
 



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 22 20:36:24 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match-escape.mk

Log Message:
tests/make: demonstrate inconsistency in pattern matching with ranges


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-match-escape.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match-escape.mk
diff -u src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.8 src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.8	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-match-escape.mk	Thu Jun 22 20:36:24 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match-escape.mk,v 1.8 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: varmod-match-escape.mk,v 1.9 2023/06/22 20:36:24 rillig Exp $
 #
 # As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
 # depending on whether there was a variable expression somewhere before the
@@ -77,12 +77,39 @@ VALUES=		: :: :\:
 #
 # TODO: Str_Match("a-z]", "[a-z]")
 # TODO: Str_Match("012", "[0-]]")
-# TODO: Str_Match("0]", "[0-]]")
-# TODO: Str_Match("1]", "[0-]]")
 # TODO: Str_Match("[", "[[]")
 # TODO: Str_Match("]", "[]")
 # TODO: Str_Match("]", "[[-]]")
 
+# Demonstrate an inconsistency between positive and negative character lists
+# when the range ends with the character ']'.
+#
+# 'A' begins the range, 'B' is in the middle of the range, ']' ends the range,
+# 'a' is outside the range.
+WORDS=		A A] A]] B B] B]] ] ]] ]]] a a] a]]
+# The ']' is part of the character range and at the same time ends the
+# character list.
+EXP.[A-]=	A B ]
+# The first ']' is part of the character range and at the same time ends the
+# character list.
+EXP.[A-]]=	A] B] ]]
+# The first ']' is part of the character range and at the same time ends the
+# character list.
+EXP.[A-]]]=	A]] B]] ]]]
+# For negative character lists, the ']' ends the character range but does not
+# end the character list.
+# XXX: This is unnecessarily inconsistent but irrelevant in practice as there
+# is no practical need for a character range that ends at ']'.
+EXP.[^A-]=	a
+EXP.[^A-]]=	a
+EXP.[^A-]]]=	a]
+
+.for pattern in [A-] [A-]] [A-]]] [^A-] [^A-]] [^A-]]]
+.  if ${WORDS:M${pattern}} != ${EXP.${pattern}}
+.warning ${pattern}: ${WORDS:M${pattern}} != ${EXP.${pattern}}
+.  endif
+.endfor
+
 # In brackets, the backslash is just an ordinary character.
 # Outside brackets, it is an escape character for a few special characters.
 # TODO: Str_Match("\\", "[\\-]]")



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 22 20:36:24 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match-escape.mk

Log Message:
tests/make: demonstrate inconsistency in pattern matching with ranges


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-match-escape.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 22 13:02:42 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in test result, since the previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-match.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-match.exp
diff -u src/usr.bin/make/unit-tests/varmod-match.exp:1.8 src/usr.bin/make/unit-tests/varmod-match.exp:1.9
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.8	Thu Jun 22 09:09:08 2023
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Thu Jun 22 13:02:42 2023
@@ -10,8 +10,8 @@ CondParser_Eval: ${:Ua \$ sign:M*$$*} !=
 Comparing "$" != "$"
 CondParser_Eval: ${:Ua \$ sign any-asterisk:M*\$*} != "any-asterisk"
 Comparing "any-asterisk" != "any-asterisk"
-make: "varmod-match.mk" line 160: Unknown modifier "]"
-make: "varmod-match.mk" line 160: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 161: Unknown modifier "]"
+make: "varmod-match.mk" line 161: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1



CVS commit: src/usr.bin/make/unit-tests

2023-06-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jun 22 13:02:42 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: varmod-match.exp

Log Message:
tests/make: fix line numbers in test result, since the previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-match.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Jun 21 21:21:52 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
Cleanup guard tests

The .PARSEFILE:tA tests add no value, the correct form
is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.10 -r1.11 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.9 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.10
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.9	Wed Jun 21 14:33:36 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Wed Jun 21 21:21:52 2023
@@ -73,12 +73,6 @@ Parse_PushInput: file target-indirect-PA
 Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is defined
 Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1
 Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined
-Parse_PushInput: file target-indirect-PARSEFILE-tA.tmp, line 1
-Skipping 'target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined
-Parse_PushInput: file subdir/target-indirect-PARSEFILE-tA.tmp, line 1
-Skipping 'subdir/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined
-Parse_PushInput: file subdir2/target-indirect-PARSEFILE-tA.tmp, line 1
-Skipping 'subdir2/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined
 Parse_PushInput: file target-indirect-PARSEDIR-PARSEFILE.tmp, line 1
 Skipping 'target-indirect-PARSEDIR-PARSEFILE.tmp' because '__target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined
 Parse_PushInput: file subdir/target-indirect-PARSEDIR-PARSEFILE.tmp, line 1

Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.10 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.11
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.10	Wed Jun 21 14:33:36 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Wed Jun 21 21:21:52 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.10 2023/06/21 14:33:36 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.11 2023/06/21 21:21:52 sjg Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -460,49 +460,8 @@ LINES.subdir/target-indirect-PARSEFILE= 
 # expect: Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1
 # expect: Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined
 
-# Another common form of guard target is __${.PARSEFILE:tA}__.  This form only
-# works for files that are in the current working directory, it does not work
-# for files from other directories, as the modifier ':tA' resolves a file
-# relative to the current working directory ('.OBJDIR').  To get a robust
-# pattern, use __${.PARSEDIR}/.${.PARSEFILE}__ instead.
-INCS+=	target-indirect-PARSEFILE-tA
-LINES.target-indirect-PARSEFILE-tA= \
-	'.if !target(__$${.PARSEFILE:tA}__)' \
-	'__$${.PARSEFILE:tA}__: .NOTMAIN' \
-	'.endif'
-# expect: Parse_PushInput: file target-indirect-PARSEFILE-tA.tmp, line 1
-# expect: Skipping 'target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined
-# The actual target starts with '__${.OBJDIR}/', see the .rawout file, but the
-# string '${.OBJDIR}/' gets stripped in post processing.
-
-# Using the ':tA' modifier to construct guard target names is generally wrong,
-# as the ':tA' modifier only works for files in the current working directory.
-# For files from subdirectories that are not also found in the current working
-# directory, applying the modifier ':tA' has no effect.
-INCS+=	subdir/target-indirect-PARSEFILE-tA
-LINES.subdir/target-indirect-PARSEFILE-tA= \
-	'.if !target(__$${.PARSEFILE:tA}__)' \
-	'__$${.PARSEFILE:tA}__: .NOTMAIN' \
-	'.endif'
-# expect: Parse_PushInput: file subdir/target-indirect-PARSEFILE-tA.tmp, line 1
-# expect: Skipping 'subdir/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined
-# The guard target name does not include any directory since the ':tA'
-# modifier file cannot resolve the file in the current working directory.
-
-# If there are two subdirectories that both have a file with the same basename
-# that uses '${.PARSEFILE:tA}' as its guard target, the second file reuses the
-# guard name from the first file.  To get a robust scheme of guard target
-# names, use 

CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Jun 21 21:21:52 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
Cleanup guard tests

The .PARSEFILE:tA tests add no value, the correct form
is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.10 -r1.11 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 12:27:50 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: dep-wildcards.mk

Log Message:
tests/make: document how wildcards behave in a dependency declaration


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/dep-wildcards.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 12:27:50 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: dep-wildcards.mk

Log Message:
tests/make: document how wildcards behave in a dependency declaration


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/dep-wildcards.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/dep-wildcards.mk
diff -u src/usr.bin/make/unit-tests/dep-wildcards.mk:1.3 src/usr.bin/make/unit-tests/dep-wildcards.mk:1.4
--- src/usr.bin/make/unit-tests/dep-wildcards.mk:1.3	Tue Sep  8 05:33:05 2020
+++ src/usr.bin/make/unit-tests/dep-wildcards.mk	Wed Jun 21 12:27:50 2023
@@ -1,4 +1,4 @@
-# $NetBSD: dep-wildcards.mk,v 1.3 2020/09/08 05:33:05 rillig Exp $
+# $NetBSD: dep-wildcards.mk,v 1.4 2023/06/21 12:27:50 rillig Exp $
 #
 # Tests for wildcards such as *.c in dependency declarations.
 
@@ -7,3 +7,9 @@ all: ${.PARSEDIR}/dep-*.mk
 	# The :O is necessary since the result of the dependency resolution
 	# does not order the directory entries itself.
 	@printf '%s\n' ${.ALLSRC:T:O}
+
+# This is not a wildcard rule as implemented by GNU make, as those rules would
+# use '%' instead of '*'.  Instead, the pattern '*.target' is a file pattern
+# in the current working directory.  As there are no such files, the target
+# list becomes empty, and the source pattern '*.source' is not even expanded.
+*.target: *.source



CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 12:16:31 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: clean up and extend tests for multiple-inclusion guards

Multiple-inclusion guards can be defined either as variables or as
targets.  Rename the variable tests so they include the word 'variable'.

Add tests to cover special characters in guard names (both variable and
target), just in case ParseVarnameGuard gets removed someday.

Document the pitfalls associated with choosing a naming scheme for
guards that leads to name clashes, such as with .PARSEFILE without
.PARSEDIR.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.8 -r1.9 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.7 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.8
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.7	Wed Jun 21 04:20:21 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Wed Jun 21 12:16:31 2023
@@ -1,41 +1,50 @@
-Parse_PushInput: file guarded-ifndef.tmp, line 1
-Skipping 'guarded-ifndef.tmp' because 'GUARDED_IFNDEF' is defined
+Parse_PushInput: file variable-ifndef.tmp, line 1
+Skipping 'variable-ifndef.tmp' because 'VARIABLE_IFNDEF' is defined
 Parse_PushInput: file comments.tmp, line 1
 Skipping 'comments.tmp' because 'COMMENTS' is defined
-Parse_PushInput: file guarded-if.tmp, line 1
-Skipping 'guarded-if.tmp' because 'GUARDED_IF' is defined
-Parse_PushInput: file triple-negation.tmp, line 1
-Parse_PushInput: file triple-negation.tmp, line 1
-Parse_PushInput: file ifdef-negated.tmp, line 1
-Parse_PushInput: file ifdef-negated.tmp, line 1
-Parse_PushInput: file varname-mismatch.tmp, line 1
-Parse_PushInput: file varname-mismatch.tmp, line 1
-Parse_PushInput: file ifndef-plus.tmp, line 1
-Parse_PushInput: file ifndef-plus.tmp, line 1
-Parse_PushInput: file if-plus.tmp, line 1
-Parse_PushInput: file if-plus.tmp, line 1
-Parse_PushInput: file ifndef-indirect.tmp, line 1
-Parse_PushInput: file ifndef-indirect.tmp, line 1
-Parse_PushInput: file if-indirect.tmp, line 1
-Parse_PushInput: file if-indirect.tmp, line 1
-Parse_PushInput: file varassign-indirect.tmp, line 1
-Skipping 'varassign-indirect.tmp' because 'VARASSIGN_INDIRECT' is defined
-Parse_PushInput: file late-assignment.tmp, line 1
-Skipping 'late-assignment.tmp' because 'LATE_ASSIGNMENT' is defined
-Parse_PushInput: file two-conditions.tmp, line 1
-Skipping 'two-conditions.tmp' because 'TWO_CONDITIONS' is defined
-Parse_PushInput: file already-set.tmp, line 1
-Parse_PushInput: file already-set.tmp, line 1
-Parse_PushInput: file twice.tmp, line 1
-Parse_PushInput: file twice.tmp, line 1
-Parse_PushInput: file reuse.tmp, line 1
-Parse_PushInput: file reuse.tmp, line 1
-Parse_PushInput: file swapped.tmp, line 1
-Parse_PushInput: file swapped.tmp, line 1
-Parse_PushInput: file undef-between.tmp, line 1
-Parse_PushInput: file undef-between.tmp, line 1
-Parse_PushInput: file undef-inside.tmp, line 1
-Parse_PushInput: file undef-inside.tmp, line 1
+Parse_PushInput: file variable-if.tmp, line 1
+Skipping 'variable-if.tmp' because 'VARIABLE_IF' is defined
+Parse_PushInput: file variable-if-triple-negation.tmp, line 1
+Parse_PushInput: file variable-if-triple-negation.tmp, line 1
+Parse_PushInput: file variable-ifdef-negated.tmp, line 1
+Parse_PushInput: file variable-ifdef-negated.tmp, line 1
+Parse_PushInput: file variable-name-mismatch.tmp, line 1
+Parse_PushInput: file variable-name-mismatch.tmp, line 1
+Parse_PushInput: file variable-name-exclamation.tmp, line 1
+Parse_PushInput: file variable-name-exclamation.tmp, line 1
+Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1
+Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1
+Parse_PushInput: file variable-name-parentheses.tmp, line 1
+Parse_PushInput: file variable-name-parentheses.tmp, line 1
+Parse_PushInput: file variable-ifndef-plus.tmp, line 1
+Parse_PushInput: file variable-ifndef-plus.tmp, line 1
+Parse_PushInput: file variable-if-plus.tmp, line 1
+Parse_PushInput: file variable-if-plus.tmp, line 1
+Parse_PushInput: file variable-ifndef-indirect.tmp, line 1
+Parse_PushInput: file variable-ifndef-indirect.tmp, line 1
+Parse_PushInput: file variable-if-indirect.tmp, line 1
+Parse_PushInput: file variable-if-indirect.tmp, line 1
+Parse_PushInput: file variable-assign-indirect.tmp, line 1
+Skipping 'variable-assign-indirect.tmp' because 'VARIABLE_ASSIGN_INDIRECT' is defined
+Parse_PushInput: file variable-assign-late.tmp, line 1
+Skipping 'variable-assign-late.tmp' 

CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 12:16:31 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: clean up and extend tests for multiple-inclusion guards

Multiple-inclusion guards can be defined either as variables or as
targets.  Rename the variable tests so they include the word 'variable'.

Add tests to cover special characters in guard names (both variable and
target), just in case ParseVarnameGuard gets removed someday.

Document the pitfalls associated with choosing a naming scheme for
guards that leads to name clashes, such as with .PARSEFILE without
.PARSEDIR.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.8 -r1.9 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 07:30:51 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-op-append.mk varname-dot-parsedir.exp
varname-dot-parsedir.mk varname-dot-parsefile.exp
varname-dot-parsefile.mk

Log Message:
tests/make: document a few tests


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-append.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varname-dot-parsefile.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varname-dot-parsefile.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-op-append.mk
diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.9 src/usr.bin/make/unit-tests/var-op-append.mk:1.10
--- src/usr.bin/make/unit-tests/var-op-append.mk:1.9	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/unit-tests/var-op-append.mk	Wed Jun 21 07:30:50 2023
@@ -1,7 +1,20 @@
-# $NetBSD: var-op-append.mk,v 1.9 2021/04/04 10:13:09 rillig Exp $
+# $NetBSD: var-op-append.mk,v 1.10 2023/06/21 07:30:50 rillig Exp $
 #
-# Tests for the += variable assignment operator, which appends to a variable,
-# creating it if necessary.
+# Tests for the '+=' variable assignment operator, which appends to a
+# variable, creating it if necessary.
+#
+# See also
+#	var-op.mk
+#
+# Standards
+#	The '+=' variable assignment operator is planned to be added in
+#	POSIX.1-202x.
+#
+#	This implementation does not support the immediate-expansion macros
+#	specified in POSIX.1-202x.  All variables are delayed-expansion.
+#
+# History
+#	The '+=' variable assignment operator was added before 1993-03-21.
 
 # Appending to an undefined variable is possible.
 # The variable is created, and no extra space is added before the value.

Index: src/usr.bin/make/unit-tests/varname-dot-parsedir.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.5 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.6
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.exp:1.5	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.exp	Wed Jun 21 07:30:50 2023
@@ -1,5 +1,5 @@
-make: "varname-dot-parsedir.mk" line 29: At this point, .PARSEDIR is undefined.
-make: "" line 35: The location can be faked in some cases.
-make: "varname-dot-parsedir.mk" line 40: The location is no longer fake.
+make: "varname-dot-parsedir.mk" line 37: At this point, .PARSEDIR is undefined.
+make: "" line 43: The location can be faked in some cases.
+make: "varname-dot-parsedir.mk" line 48: The location is no longer fake.
 At run time, .PARSEDIR is undefined.
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.7 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.8
--- src/usr.bin/make/unit-tests/varname-dot-parsedir.mk:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varname-dot-parsedir.mk	Wed Jun 21 07:30:50 2023
@@ -1,7 +1,15 @@
-# $NetBSD: varname-dot-parsedir.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: varname-dot-parsedir.mk,v 1.8 2023/06/21 07:30:50 rillig Exp $
 #
 # Tests for the special .PARSEDIR variable, which contains the directory part
 # of the file that is currently parsed.
+#
+# See also
+#	varname-dot-includedfromdir.mk
+#	varname-dot-includedfromfile.mk
+#	varname-dot-parsefile.mk
+#
+# History
+#	.PARSEDIR and .PARSEFILE were added on 1999-08-09.
 
 # The .PARSEDIR may be absolute or relative, therefore there is not much that
 # can be tested here.

Index: src/usr.bin/make/unit-tests/varname-dot-parsefile.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.4 src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.5
--- src/usr.bin/make/unit-tests/varname-dot-parsefile.exp:1.4	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varname-dot-parsefile.exp	Wed Jun 21 07:30:50 2023
@@ -1,5 +1,5 @@
-make: "varname-dot-parsefile.mk" line 24: At this point, .PARSEFILE is undefined.
-make: "" line 30: The location can be faked in some cases.
-make: "varname-dot-parsefile.mk" line 35: The location is no longer fake.
+make: "varname-dot-parsefile.mk" line 32: At this point, .PARSEFILE is undefined.
+make: "" line 38: The location can be faked in some cases.
+make: "varname-dot-parsefile.mk" line 43: The location is no longer fake.
 At run time, .PARSEFILE is undefined.
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-dot-parsefile.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.6 src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.7
--- src/usr.bin/make/unit-tests/varname-dot-parsefile.mk:1.6	Thu Jun  1 20:56:35 2023
+++ 

CVS commit: src/usr.bin/make/unit-tests

2023-06-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 21 07:30:51 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-op-append.mk varname-dot-parsedir.exp
varname-dot-parsedir.mk varname-dot-parsefile.exp
varname-dot-parsefile.mk

Log Message:
tests/make: document a few tests


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-append.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-parsedir.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-dot-parsedir.mk
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varname-dot-parsefile.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varname-dot-parsefile.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun 19 20:44:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-ifndef.exp directive-ifndef.mk

Log Message:
tests/make: test triple negation in '.ifndef'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-ifndef.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-ifndef.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-ifndef.exp
diff -u src/usr.bin/make/unit-tests/directive-ifndef.exp:1.5 src/usr.bin/make/unit-tests/directive-ifndef.exp:1.6
--- src/usr.bin/make/unit-tests/directive-ifndef.exp:1.5	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-ifndef.exp	Mon Jun 19 20:44:06 2023
@@ -1,2 +1,2 @@
-make: "directive-ifndef.mk" line 11: guarded section
+make: "directive-ifndef.mk" line 14: guarded section
 exit status 0

Index: src/usr.bin/make/unit-tests/directive-ifndef.mk
diff -u src/usr.bin/make/unit-tests/directive-ifndef.mk:1.7 src/usr.bin/make/unit-tests/directive-ifndef.mk:1.8
--- src/usr.bin/make/unit-tests/directive-ifndef.mk:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-ifndef.mk	Mon Jun 19 20:44:06 2023
@@ -1,9 +1,12 @@
-# $NetBSD: directive-ifndef.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: directive-ifndef.mk,v 1.8 2023/06/19 20:44:06 rillig Exp $
 #
 # Tests for the .ifndef directive, which can be used for multiple-inclusion
 # guards.  In contrast to C, where #ifndef and #define nicely line up the
 # macro name, there is no such syntax in make.  Therefore, it is more
 # common to use .if !defined(GUARD) instead.
+#
+# See also:
+#	directive-include-guard.mk
 
 .ifndef GUARD
 GUARD=	# defined
@@ -21,5 +24,30 @@ GUARD=	# defined
 .  info guarded section
 .endif
 
+
+# The '.ifndef' directive can be used with multiple arguments, even negating
+# them.  Since these conditions are confusing for humans, they should be
+# replaced with easier-to-understand plain '.if' directives.
+DEFINED=
+.ifndef UNDEFINED && UNDEFINED
+.else
+.  error
+.endif
+.ifndef UNDEFINED && DEFINED
+.  error
+.endif
+.ifndef DEFINED && DEFINED
+.  error
+.endif
+.ifndef !UNDEFINED && !UNDEFINED
+.  error
+.endif
+.ifndef !UNDEFINED && !DEFINED
+.  error
+.endif
+.ifndef !DEFINED && !DEFINED
+.else
+.  error
+.endif
+
 all:
-	@:;



CVS commit: src/usr.bin/make/unit-tests

2023-06-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jun 19 20:44:06 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-ifndef.exp directive-ifndef.mk

Log Message:
tests/make: test triple negation in '.ifndef'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-ifndef.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-ifndef.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Jun 19 15:37:48 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-readonly.mk

Log Message:
Test that .undef of readOnly variable fails


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-readonly.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/var-readonly.mk
diff -u src/usr.bin/make/unit-tests/var-readonly.mk:1.2 src/usr.bin/make/unit-tests/var-readonly.mk:1.3
--- src/usr.bin/make/unit-tests/var-readonly.mk:1.2	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-readonly.mk	Mon Jun 19 15:37:48 2023
@@ -1,4 +1,4 @@
-# $NetBSD: var-readonly.mk,v 1.2 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: var-readonly.mk,v 1.3 2023/06/19 15:37:48 sjg Exp $
 
 # the answer
 N = 42
@@ -9,6 +9,12 @@ N = 666
 .error N ($N) should be 42
 .endif
 
+# undef should fail
+.undef N
+.ifndef N
+.error N should not be undef'd
+.endif
+
 .NOREADONLY: N
 # now we can change it
 N = 69



CVS commit: src/usr.bin/make/unit-tests

2023-06-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Jun 19 15:37:48 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: var-readonly.mk

Log Message:
Test that .undef of readOnly variable fails


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-readonly.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 18 20:43:53 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: clean up test for multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2023-06-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 18 20:43:53 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.exp
directive-include-guard.mk

Log Message:
tests/make: clean up test for multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/directive-include-guard.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.2 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.3
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.2	Sun Jun 18 19:16:51 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Sun Jun 18 20:43:52 2023
@@ -1,35 +1,35 @@
-Parse_PushInput: file directive-include-guard-guarded-ifndef.tmp, line 1
-Parse_PushInput: file directive-include-guard-guarded-ifndef.tmp, line 1
-Parse_PushInput: file directive-include-guard-comments.tmp, line 1
-Parse_PushInput: file directive-include-guard-comments.tmp, line 1
-Parse_PushInput: file directive-include-guard-guarded-if.tmp, line 1
-Parse_PushInput: file directive-include-guard-guarded-if.tmp, line 1
-Parse_PushInput: file directive-include-guard-triple-negation.tmp, line 1
-Parse_PushInput: file directive-include-guard-triple-negation.tmp, line 1
-Parse_PushInput: file directive-include-guard-varname-mismatch.tmp, line 1
-Parse_PushInput: file directive-include-guard-varname-mismatch.tmp, line 1
-Parse_PushInput: file directive-include-guard-varname-indirect.tmp, line 1
-Parse_PushInput: file directive-include-guard-varname-indirect.tmp, line 1
-Parse_PushInput: file directive-include-guard-late-assignment.tmp, line 1
-Parse_PushInput: file directive-include-guard-late-assignment.tmp, line 1
-Parse_PushInput: file directive-include-guard-two-conditions.tmp, line 1
-Parse_PushInput: file directive-include-guard-two-conditions.tmp, line 1
-Parse_PushInput: file directive-include-guard-already-set.tmp, line 1
-Parse_PushInput: file directive-include-guard-already-set.tmp, line 1
-Parse_PushInput: file directive-include-guard-twice.tmp, line 1
-Parse_PushInput: file directive-include-guard-twice.tmp, line 1
-Parse_PushInput: file directive-include-guard-reuse.tmp, line 1
-Parse_PushInput: file directive-include-guard-reuse.tmp, line 1
-Parse_PushInput: file directive-include-guard-swapped.tmp, line 1
-Parse_PushInput: file directive-include-guard-swapped.tmp, line 1
-Parse_PushInput: file directive-include-guard-undef-between.tmp, line 1
-Parse_PushInput: file directive-include-guard-undef-between.tmp, line 1
-Parse_PushInput: file directive-include-guard-undef-inside.tmp, line 1
-Parse_PushInput: file directive-include-guard-undef-inside.tmp, line 1
-Parse_PushInput: file directive-include-guard-if-elif.tmp, line 1
-Parse_PushInput: file directive-include-guard-if-elif.tmp, line 1
-Parse_PushInput: file directive-include-guard-if-else.tmp, line 1
-Parse_PushInput: file directive-include-guard-if-else.tmp, line 1
-Parse_PushInput: file directive-include-guard-inner-if-elif-else.tmp, line 1
-Parse_PushInput: file directive-include-guard-inner-if-elif-else.tmp, line 1
+Parse_PushInput: file guarded-ifndef.tmp, line 1
+Parse_PushInput: file guarded-ifndef.tmp, line 1
+Parse_PushInput: file comments.tmp, line 1
+Parse_PushInput: file comments.tmp, line 1
+Parse_PushInput: file guarded-if.tmp, line 1
+Parse_PushInput: file guarded-if.tmp, line 1
+Parse_PushInput: file triple-negation.tmp, line 1
+Parse_PushInput: file triple-negation.tmp, line 1
+Parse_PushInput: file varname-mismatch.tmp, line 1
+Parse_PushInput: file varname-mismatch.tmp, line 1
+Parse_PushInput: file varname-indirect.tmp, line 1
+Parse_PushInput: file varname-indirect.tmp, line 1
+Parse_PushInput: file late-assignment.tmp, line 1
+Parse_PushInput: file late-assignment.tmp, line 1
+Parse_PushInput: file two-conditions.tmp, line 1
+Parse_PushInput: file two-conditions.tmp, line 1
+Parse_PushInput: file already-set.tmp, line 1
+Parse_PushInput: file already-set.tmp, line 1
+Parse_PushInput: file twice.tmp, line 1
+Parse_PushInput: file twice.tmp, line 1
+Parse_PushInput: file reuse.tmp, line 1
+Parse_PushInput: file reuse.tmp, line 1
+Parse_PushInput: file swapped.tmp, line 1
+Parse_PushInput: file swapped.tmp, line 1
+Parse_PushInput: file undef-between.tmp, line 1
+Parse_PushInput: file undef-between.tmp, line 1
+Parse_PushInput: file undef-inside.tmp, line 1
+Parse_PushInput: file undef-inside.tmp, line 1
+Parse_PushInput: file if-elif.tmp, line 1
+Parse_PushInput: file if-elif.tmp, line 1
+Parse_PushInput: file if-else.tmp, line 1
+Parse_PushInput: file if-else.tmp, line 1
+Parse_PushInput: file inner-if-elif-else.tmp, line 1

CVS commit: src/usr.bin/make/unit-tests

2023-06-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 18 19:30:31 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.mk

Log Message:
tests/make: align variable name in test for multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.2 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.3
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.2	Sun Jun 18 19:16:51 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Sun Jun 18 19:30:31 2023
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.2 2023/06/18 19:16:51 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.3 2023/06/18 19:30:31 rillig Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -30,9 +30,9 @@ INCS+=	comments
 LINES.comments= \
 	'\# comment' \
 	'' \
-	'.ifndef GUARD' \
+	'.ifndef COMMENTS' \
 	'\# comment' \
-	'GUARD=\#comment' \
+	'COMMENTS=\#comment' \
 	'.endif' \
 	'\# comment'
 



CVS commit: src/usr.bin/make/unit-tests

2023-06-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 18 19:30:31 UTC 2023

Modified Files:
src/usr.bin/make/unit-tests: directive-include-guard.mk

Log Message:
tests/make: align variable name in test for multiple-inclusion guards


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/directive-include-guard.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   3   4   5   6   7   8   9   10   >