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

2022-08-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 23 17:40:43 UTC 2022

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

Log Message:
tests/make: demonstrate parse error in ':@' modifier (since 2022-08-08)

Reported by sjg via private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-loop.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

2022-08-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 23 16:36:02 UTC 2022

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

Log Message:
tests/make: demonstrate that .for variables take precedence


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.mk
diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.13 src/usr.bin/make/unit-tests/directive-for.mk:1.14
--- src/usr.bin/make/unit-tests/directive-for.mk:1.13	Sat Jan 15 12:35:18 2022
+++ src/usr.bin/make/unit-tests/directive-for.mk	Tue Aug 23 16:36:02 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for.mk,v 1.13 2022/01/15 12:35:18 rillig Exp $
+# $NetBSD: directive-for.mk,v 1.14 2022/08/23 16:36:02 rillig Exp $
 #
 # Tests for the .for directive.
 #
@@ -228,3 +228,19 @@ var=	outer
endfor
 .endfor
 .MAKEFLAGS: -d0
+
+
+# When there is a variable definition 'scope=cmdline' from the command line
+# (which has higher precedence than global variables) and a .for loop iterates
+# over a variable of the same name, the expression '${scope}' expands to the
+# value from the .for loop.  This is because when the body of the .for loop is
+# expanded, the expression '${scope}' is textually replaced with ${:Uloop}',
+# without resolving any variable names.  Later, when the body of the .for loop
+# is actually interpreted, the body text doesn't contain the word 'scope'
+# anymore.
+.MAKEFLAGS: scope=cmdline
+.for scope in loop
+.  if ${scope} != "loop"
+.error
+.  endif
+.endfor



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

2022-08-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 23 16:36:02 UTC 2022

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

Log Message:
tests/make: demonstrate that .for variables take precedence


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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

2022-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 18 05:37:05 UTC 2022

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

Log Message:
tests/make: fix test for option '-q' in ATF mode

When running 'make test' in usr.bin/make, MAKE is set to '$PWD/make',
and when that file is used as a dependency, everything works as
expected.

When running the tests via ATF, MAKE is set to simply 'make', based on
argv[0].  Using 'make' as a dependency searches in the current directory
but not in /usr/bin, so the file is not found, which makes the
"up-to-date" target out of date.

Switch the dependeny from ${MAKE} to ${MAKEFILE}, as that file does not
involve any $PATH magic and is also guaranteed to be older than the
'up-to-date' file that is created while running the test.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-query.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-query.mk
diff -u src/usr.bin/make/unit-tests/opt-query.mk:1.6 src/usr.bin/make/unit-tests/opt-query.mk:1.7
--- src/usr.bin/make/unit-tests/opt-query.mk:1.6	Wed Aug 17 20:10:29 2022
+++ src/usr.bin/make/unit-tests/opt-query.mk	Thu Aug 18 05:37:05 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-query.mk,v 1.6 2022/08/17 20:10:29 rillig Exp $
+# $NetBSD: opt-query.mk,v 1.7 2022/08/18 05:37:05 rillig Exp $
 #
 # Tests for the -q command line option.
 #
@@ -76,8 +76,8 @@ commands:
 
 .elif ${PART} == "variants"
 
-opt-query-file.out-of-date: ${MAKE}
-opt-query-file.up-to-date: ${MAKE}
+opt-query-file.out-of-date: ${MAKEFILE}
+opt-query-file.up-to-date: ${MAKEFILE}
 phony: .PHONY
 
 .else



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

2022-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 18 05:37:05 UTC 2022

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

Log Message:
tests/make: fix test for option '-q' in ATF mode

When running 'make test' in usr.bin/make, MAKE is set to '$PWD/make',
and when that file is used as a dependency, everything works as
expected.

When running the tests via ATF, MAKE is set to simply 'make', based on
argv[0].  Using 'make' as a dependency searches in the current directory
but not in /usr/bin, so the file is not found, which makes the
"up-to-date" target out of date.

Switch the dependeny from ${MAKE} to ${MAKEFILE}, as that file does not
involve any $PATH magic and is also guaranteed to be older than the
'up-to-date' file that is created while running the test.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-query.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

2022-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 17 20:05:41 UTC 2022

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

Log Message:
tests/make: demonstrate wrong exit status for '-q' (since 1994)

Reported by Jeroen Ruigrok van der Werven via private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-query.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-query.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-query.exp
diff -u src/usr.bin/make/unit-tests/opt-query.exp:1.2 src/usr.bin/make/unit-tests/opt-query.exp:1.3
--- src/usr.bin/make/unit-tests/opt-query.exp:1.2	Wed Aug 19 05:13:18 2020
+++ src/usr.bin/make/unit-tests/opt-query.exp	Wed Aug 17 20:05:41 2022
@@ -1,2 +1,24 @@
+Making commands:
 command during parsing
-exit status 1
+commands: query status 1
+
+Making opt-query-file.out-of-date in compat mode:
+opt-query-file.out-of-date in compat mode: query status 1
+
+Making opt-query-file.up-to-date in compat mode:
+`opt-query-file.up-to-date' is up to date.
+opt-query-file.up-to-date in compat mode: query status 1
+
+Making phony in compat mode:
+phony in compat mode: query status 1
+
+Making opt-query-file.out-of-date in jobs mode:
+opt-query-file.out-of-date in jobs mode: query status 1
+
+Making opt-query-file.up-to-date in jobs mode:
+opt-query-file.up-to-date in jobs mode: query status 1
+
+Making phony in jobs mode:
+phony in jobs mode: query status 1
+
+exit status 0

Index: src/usr.bin/make/unit-tests/opt-query.mk
diff -u src/usr.bin/make/unit-tests/opt-query.mk:1.4 src/usr.bin/make/unit-tests/opt-query.mk:1.5
--- src/usr.bin/make/unit-tests/opt-query.mk:1.4	Mon Nov  9 20:50:56 2020
+++ src/usr.bin/make/unit-tests/opt-query.mk	Wed Aug 17 20:05:41 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-query.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $
+# $NetBSD: opt-query.mk,v 1.5 2022/08/17 20:05:41 rillig Exp $
 #
 # Tests for the -q command line option.
 #
@@ -6,7 +6,59 @@
 # None of the commands in the targets are run, not even those that are
 # prefixed with '+'.
 
-.MAKEFLAGS: -q
+# This test consists of several parts:
+#
+#	main		Delegates to the actual tests.
+#
+#	commands	Ensures that none of the targets is made.
+#
+#	variants	Ensures that the up-to-date status is correctly
+#			reported in both compat and jobs mode, and for several
+#			kinds of make targets.
+PART?=	main
+
+.if ${PART} == "main"
+
+all: .PHONY variants cleanup
+
+_!=	touch -f opt-query-file.up-to-date
+
+variants: .PHONY
+.  for target in commands
+	@echo 'Making ${target}':
+	@${MAKE} -r -f ${MAKEFILE} -q ${mode:Mjobs:%=-j1} ${target} PART=commands \
+	&& echo "${target}: query status $$?" \
+	|| echo "${target}: query status $$?"
+	@echo
+.  endfor
+.  for mode in compat jobs
+.for target in opt-query-file.out-of-date opt-query-file.up-to-date phony
+	@echo 'Making ${target} in ${mode} mode':
+	@${MAKE} -r -f ${MAKEFILE} -q ${mode:Mjobs:%=-j1} ${target} PART=variants \
+	&& echo "${target} in ${mode} mode: query status $$?" \
+	|| echo "${target} in ${mode} mode: query status $$?"
+	@echo
+.endfor
+.  endfor
+
+# expect: opt-query-file.out-of-date in compat mode: query status 1
+
+# FIXME: must be 0, not 1.
+# expect: opt-query-file.up-to-date in compat mode: query status 1
+
+# expect: phony in compat mode: query status 1
+
+# expect: opt-query-file.out-of-date in jobs mode: query status 1
+
+# FIXME: must be 0, not 1.
+# expect: opt-query-file.up-to-date in jobs mode: query status 1
+
+# expect: phony in jobs mode: query status 1
+
+cleanup: .PHONY
+	@rm -f opt-query-file.up-to-date
+
+.elif ${PART} == "commands"
 
 # This command cannot be prevented from being run since it is used at parse
 # time, and any later variable assignments may depend on its result.
@@ -18,9 +70,18 @@
 	@+echo '$@: run always'
 
 # None of these commands are run.
-all:
+commands:
 	@echo '$@: hidden command'
 	@+echo '$@: run always'
-
-# The exit status 1 is because the "all" target has to be made, that is,
+# The exit status 1 is because the "commands" target has to be made, that is,
 # it is not up-to-date.
+
+.elif ${PART} == "variants"
+
+opt-query-file.out-of-date: ${MAKE}
+opt-query-file.up-to-date: ${MAKE}
+phony: .PHONY
+
+.else
+.  error Invalid part '${PART}'
+.endif



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

2022-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 17 20:05:41 UTC 2022

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

Log Message:
tests/make: demonstrate wrong exit status for '-q' (since 1994)

Reported by Jeroen Ruigrok van der Werven via private mail.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-query.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-query.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

2022-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  8 19:53:28 UTC 2022

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

Log Message:
tests/make: document history of bug in parsing unbalanced expressions

The bug was introduced in var.c 1.323, which merged two flags that
sounded as if they had been exact opposites: VAR_NOSUBST (later named
VARE_NOSUBST) and VARE_WANTRES.

Before that commit, the branch where make only counted braces instead of
properly parsing the nested expression was only taken in the modifiers
':@var@body@' and '::=', but not in ':S' and ':C'.

After merging the two flags, the modifier parts of ':S' and ':C' had to
be balanced as well, otherwise parsing would fail in cases where the
expression was only parsed, not evaluated.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/parse-var.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/parse-var.mk
diff -u src/usr.bin/make/unit-tests/parse-var.mk:1.3 src/usr.bin/make/unit-tests/parse-var.mk:1.4
--- src/usr.bin/make/unit-tests/parse-var.mk:1.3	Mon Aug  8 18:23:30 2022
+++ src/usr.bin/make/unit-tests/parse-var.mk	Mon Aug  8 19:53:28 2022
@@ -1,4 +1,4 @@
-# $NetBSD: parse-var.mk,v 1.3 2022/08/08 18:23:30 rillig Exp $
+# $NetBSD: parse-var.mk,v 1.4 2022/08/08 19:53:28 rillig Exp $
 #
 # Tests for parsing variable expressions.
 
@@ -14,8 +14,9 @@ VAR.${:U param }=	value
 .endif
 
 
-# Before var.c 1.1028 from 2022-08-08, the exact way of parsing an expression
-# depended on whether the expression was actually evaluated or merely parsed.
+# Since var.c 1.323 from 202-07-26 18:11 and before var.c 1.1028 from
+# 2022-08-08, the exact way of parsing an expression depended on whether the
+# expression was actually evaluated or merely parsed.
 #
 # If it was evaluated, nested expressions were parsed correctly, parsing each
 # modifier according to its exact definition (see varmod.mk).



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

2022-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  8 19:53:28 UTC 2022

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

Log Message:
tests/make: document history of bug in parsing unbalanced expressions

The bug was introduced in var.c 1.323, which merged two flags that
sounded as if they had been exact opposites: VAR_NOSUBST (later named
VARE_NOSUBST) and VARE_WANTRES.

Before that commit, the branch where make only counted braces instead of
properly parsing the nested expression was only taken in the modifiers
':@var@body@' and '::=', but not in ':S' and ':C'.

After merging the two flags, the modifier parts of ':S' and ':C' had to
be balanced as well, otherwise parsing would fail in cases where the
expression was only parsed, not evaluated.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/parse-var.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

2022-08-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  6 21:26:06 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: parse-var.exp parse-var.mk
varmod-undefined.mk

Log Message:
tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed.  This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/parse-var.exp \
src/usr.bin/make/unit-tests/parse-var.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-undefined.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/parse-var.exp
diff -u src/usr.bin/make/unit-tests/parse-var.exp:1.1 src/usr.bin/make/unit-tests/parse-var.exp:1.2
--- src/usr.bin/make/unit-tests/parse-var.exp:1.1	Sun Oct  4 06:53:15 2020
+++ src/usr.bin/make/unit-tests/parse-var.exp	Sat Aug  6 21:26:05 2022
@@ -1 +1,5 @@
-exit status 0
+make: Unfinished modifier for "BRACE_GROUP" (',' missing)
+make: "parse-var.mk" line 47: Malformed conditional (0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},,})
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/parse-var.mk
diff -u src/usr.bin/make/unit-tests/parse-var.mk:1.1 src/usr.bin/make/unit-tests/parse-var.mk:1.2
--- src/usr.bin/make/unit-tests/parse-var.mk:1.1	Sun Oct  4 06:53:15 2020
+++ src/usr.bin/make/unit-tests/parse-var.mk	Sat Aug  6 21:26:05 2022
@@ -1,13 +1,52 @@
-# $NetBSD: parse-var.mk,v 1.1 2020/10/04 06:53:15 rillig Exp $
+# $NetBSD: parse-var.mk,v 1.2 2022/08/06 21:26:05 rillig Exp $
+#
+# Tests for parsing variable expressions.
 
 .MAKEFLAGS: -dL
 
-# In variable assignments, there may be spaces on the left-hand side of the
-# assignment, but only if they occur inside variable expressions.
+# In variable assignments, there may be spaces in the middle of the left-hand
+# side of the assignment, but only if they occur inside variable expressions.
+# Leading spaces (but not tabs) are possible but unusual.
+# Trailing spaces are common in some coding styles, others omit them.
 VAR.${:U param }=	value
 .if ${VAR.${:U param }} != "value"
 .  error
 .endif
 
-all:
-	@:;
+
+# As of var.c 1.1027 from 2022-08-05, the exact way of parsing an expression
+# depends on whether the expression is actually evaluated or merely parsed.
+#
+# If it is evaluated, nested expressions are parsed correctly, parsing each
+# modifier according to its exact definition.  If the expression is merely
+# parsed but not evaluated (because its value would not influence the outcome
+# of the condition), and the expression contains a modifier, and that modifier
+# contains a nested expression, the nested expression is not parsed
+# correctly.  Instead, make only counts the opening and closing delimiters,
+# which fails for nested modifiers with unbalanced braces.
+#
+# See ParseModifierPartDollar.
+
+#.MAKEFLAGS: -dcpv
+# Keep these braces outside the conditions below, to keep them simple to
+# understand.  If the BRACE_PAIR had been replaced with ':U{}', the '}' would
+# have to be escaped, but not the '{'.  This asymmetry would have made the
+# example even more complicated to understand.
+BRACE_PAIR=	{}
+# In this test word, the '{{}' in the middle will be replaced.
+BRACE_GROUP=	
+
+# The inner ':S' modifier turns the word '{}' into '{{}'.
+# The outer ':S' modifier then replaces '{{}' with ''.
+# In the first case, the outer expression is relevant and is parsed correctly.
+.if 1 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},,}
+.endif
+# In the second case, the outer expression is irrelevant.  In this case, in
+# the parts of the outer ':S' modifier, make only counts the braces, and since
+# the inner expression '${:U...}' contains more '{' than '}', parsing fails.
+.if 0 && ${BRACE_GROUP:S,${BRACE_PAIR:S,{,{{,},,}
+.endif
+#.MAKEFLAGS: -d0
+
+
+all: .PHONY

Index: src/usr.bin/make/unit-tests/varmod-undefined.mk
diff -u src/usr.bin/make/unit-tests/varmod-undefined.mk:1.7 src/usr.bin/make/unit-tests/varmod-undefined.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-undefined.mk:1.7	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/varmod-undefined.mk	Sat Aug  6 21:26:05 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-undefined.mk,v 1.7 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: varmod-undefined.mk,v 1.8 2022/08/06 21:26:05 rillig Exp $
 #
 # Tests for the :U variable modifier, which returns the given string
 # if the variable is undefined.
@@ -29,7 +29,7 @@
 # The nested variable expressions may contain braces, and these braces don't
 # need to match pairwise.  In the following example, the :S modifier uses '{'
 # 

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

2022-08-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  6 21:26:06 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: parse-var.exp parse-var.mk
varmod-undefined.mk

Log Message:
tests/make: demonstrate bug in parsing of modifier parts

In the modifier ':S,from,to,', parsing the two parts 'from' and 'to' of
the modifier differs depending on whether the expression is actually
evaluated or merely parsed.  This not only applies to the ':S' modifier,
but also to ':C', ':@var@body@', ':!cmd!', ':[...]', ':?:', '::=' and
':from=to'.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/parse-var.exp \
src/usr.bin/make/unit-tests/parse-var.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-undefined.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

2022-08-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  6 07:06:58 UTC 2022

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

Log Message:
tests/make: document parsing behavior of modifiers

The table was created by manually inspecting the code of the various
ApplyModifier functions in var.c.

The modifiers are listed in alphabetical order, except for the SysV
modifier, which is listed at the end since it is used as a fallback
modifier for many other modifiers and because it does not have a fixed
prefix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod.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.exp
diff -u src/usr.bin/make/unit-tests/varmod.exp:1.4 src/usr.bin/make/unit-tests/varmod.exp:1.5
--- src/usr.bin/make/unit-tests/varmod.exp:1.4	Sat Dec 19 22:33:11 2020
+++ src/usr.bin/make/unit-tests/varmod.exp	Sat Aug  6 07:06:58 2022
@@ -1,8 +1,8 @@
-make: "varmod.mk" line 42: To escape a dollar, use \$, not $$, at "$$:L} != """
-make: "varmod.mk" line 42: Invalid variable name ':', at "$:L} != """
-make: "varmod.mk" line 47: Dollar followed by nothing
-make: "varmod.mk" line 56: Missing delimiter ':' after modifier "P"
-make: "varmod.mk" line 57: Missing argument for ".error"
+make: "varmod.mk" line 93: To escape a dollar, use \$, not $$, at "$$:L} != """
+make: "varmod.mk" line 93: Invalid variable name ':', at "$:L} != """
+make: "varmod.mk" line 98: Dollar followed by nothing
+make: "varmod.mk" line 107: Missing delimiter ':' after modifier "P"
+make: "varmod.mk" line 108: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod.mk
diff -u src/usr.bin/make/unit-tests/varmod.mk:1.5 src/usr.bin/make/unit-tests/varmod.mk:1.6
--- src/usr.bin/make/unit-tests/varmod.mk:1.5	Sat Dec 19 22:33:11 2020
+++ src/usr.bin/make/unit-tests/varmod.mk	Sat Aug  6 07:06:58 2022
@@ -1,7 +1,58 @@
-# $NetBSD: varmod.mk,v 1.5 2020/12/19 22:33:11 rillig Exp $
+# $NetBSD: varmod.mk,v 1.6 2022/08/06 07:06:58 rillig Exp $
 #
 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
 
+# As of 2022-08-06, the possible behaviors during parsing are:
+#
+# * `strict`: the parsing style used by most modifiers:
+#   * either uses `ParseModifierPart` or parses the modifier literal
+#   * other modifiers may follow, separated by a ':'
+#
+# * `greedy`: calls `ParseModifierPart` with `ch->endc`; this means
+#   that no further modifiers are parsed in that expression.
+#
+# * `no-colon`: after parsing this modifier, the following modifier
+#   does not need to be separated by a colon.
+#   Omitting this colon is bad style.
+#
+# * `individual`: parsing this modifier does not follow the common
+#   pattern of calling `ParseModifierPart`.
+#
+# The SysV column says whether a parse error in the modifier falls back
+# trying the `:from=to` System V modifier.
+#
+# | **Operator** | **Behavior** | **Remarks**| **SysV** |
+# |--|--||--|
+# | `!`  | no-colon || no   |
+# | `:=` | greedy   || yes  |
+# | `?:` | greedy   || no   |
+# | `@`  | no-colon || no   |
+# | `C`  | no-colon || no   |
+# | `D`  | individual   | custom parser  | N/A  |
+# | `E`  | strict   || yes  |
+# | `H`  | strict   || yes  |
+# | `L`  | no-colon || N/A  |
+# | `M`  | individual   | custom parser  | N/A  |
+# | `N`  | individual   | custom parser  | N/A  |
+# | `O`  | strict   | only literal value | no   |
+# | `P`  | no-colon || N/A  |
+# | `Q`  | strict   || yes  |
+# | `R`  | strict   || yes  |
+# | `S`  | no-colon || N/A  |
+# | `T`  | strict   || N/A  |
+# | `U`  | individual   | custom parser  | N/A  |
+# | `[`  | strict   || no   |
+# | `_`  | individual   | strcspn| yes  |
+# | `gmtime` | strict   | only literal value | yes  |
+# | `hash`   | strict   || N/A  |
+# | `localtime`  | strict   | only literal value | yes  |
+# | `q`  | strict   || yes  |
+# | `range`  | strict   || N/A  |
+# | `sh`

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

2022-08-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  6 07:06:58 UTC 2022

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

Log Message:
tests/make: document parsing behavior of modifiers

The table was created by manually inspecting the code of the various
ApplyModifier functions in var.c.

The modifiers are listed in alphabetical order, except for the SysV
modifier, which is listed at the end since it is used as a fallback
modifier for many other modifiers and because it does not have a fixed
prefix.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod.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

2022-07-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Jul 26 19:32:25 UTC 2022

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

Log Message:
Pass MAKEOBJDIR to opt-m-include-dir

Prevent makeing opt-m-include-dir.tmp in src tree.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 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.318 src/usr.bin/make/unit-tests/Makefile:1.319
--- src/usr.bin/make/unit-tests/Makefile:1.318	Fri Jun 10 21:28:50 2022
+++ src/usr.bin/make/unit-tests/Makefile	Tue Jul 26 19:32:25 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.318 2022/06/10 21:28:50 rillig Exp $
+# $NetBSD: Makefile,v 1.319 2022/07/26 19:32:25 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -469,6 +469,7 @@ TESTS:= ${TESTS:${BROKEN_TESTS:S,^,N,:ts
 ENV.depsrc-optional+=   TZ=UTC
 ENV.directive-undef=	ENV_VAR=env-value
 ENV.envfirst=		FROM_ENV=value-from-env
+ENV.opt-m-include-dir=	${MAKEOBJDIR:DMAKEOBJDIR=${MAKEOBJDIR}}
 ENV.varmisc=		FROM_ENV=env
 ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env



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

2022-07-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Jul 26 19:32:25 UTC 2022

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

Log Message:
Pass MAKEOBJDIR to opt-m-include-dir

Prevent makeing opt-m-include-dir.tmp in src tree.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.318 -r1.319 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

2022-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 10 21:11:49 UTC 2022

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

Log Message:
tests/make: extend tests for modifier ':H'


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-head.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-head.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

2022-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 10 21:11:49 UTC 2022

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

Log Message:
tests/make: extend tests for modifier ':H'


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-head.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-head.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-head.exp
diff -u src/usr.bin/make/unit-tests/varmod-head.exp:1.3 src/usr.bin/make/unit-tests/varmod-head.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-head.exp:1.3	Sun Dec 20 22:57:40 2020
+++ src/usr.bin/make/unit-tests/varmod-head.exp	Sun Jul 10 21:11:49 2022
@@ -1,11 +1 @@
-head (dirname) of 'a/b/c' is 'a/b'
-head (dirname) of 'def' is '.'
-head (dirname) of 'a.b.c' is '.'
-head (dirname) of 'a.b/c' is 'a.b'
-head (dirname) of 'a' is '.'
-head (dirname) of 'a.a' is '.'
-head (dirname) of '.gitignore' is '.'
-head (dirname) of 'a' is '.'
-head (dirname) of 'a.a' is '.'
-head (dirname) of 'trailing/' is 'trailing'
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-head.mk
diff -u src/usr.bin/make/unit-tests/varmod-head.mk:1.4 src/usr.bin/make/unit-tests/varmod-head.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-head.mk:1.4	Sun Dec 20 22:57:40 2020
+++ src/usr.bin/make/unit-tests/varmod-head.mk	Sun Jul 10 21:11:49 2022
@@ -1,9 +1,64 @@
-# $NetBSD: varmod-head.mk,v 1.4 2020/12/20 22:57:40 rillig Exp $
+# $NetBSD: varmod-head.mk,v 1.5 2022/07/10 21:11:49 rillig Exp $
 #
 # Tests for the :H variable modifier, which returns the dirname of
 # each of the words in the variable value.
 
-all:
-.for path in a/b/c def a.b.c a.b/c a a.a .gitignore a a.a trailing/
-	@echo "head (dirname) of '"${path:Q}"' is '"${path:H:Q}"'"
-.endfor
+.if ${:U a/b/c :H} != "a/b"
+.  error
+.endif
+
+.if ${:U def :H} != "."
+.  error
+.endif
+
+.if ${:U a.b.c :H} != "."
+.  error
+.endif
+
+.if ${:U a.b/c :H} != "a.b"
+.  error
+.endif
+
+.if ${:U a :H} != "."
+.  error
+.endif
+
+.if ${:U a.a :H} != "."
+.  error
+.endif
+
+.if ${:U .gitignore :H} != "."
+.  error
+.endif
+
+.if ${:U trailing/ :H} != "trailing"
+.  error
+.endif
+
+.if ${:U /abs/dir/file :H} != "/abs/dir"
+.  error
+.endif
+
+.if ${:U rel/dir/file :H} != "rel/dir"
+.  error
+.endif
+
+# The head of "/" was an empty string before 2020.07.20.14.50.41, leading to
+# the output "before  after", with two spaces.  Since 2020.07.20.14.50.41, the
+# output is "before after", discarding the empty word.
+.if ${:U before/ / after/ :H} == "before after"
+# OK
+.elif ${:U before/ / after/ :H} == "before  after"
+# No '.info' to keep the file compatible with old make versions.
+_!=	echo "The modifier ':H' generates an empty word." 1>&2; echo
+.else
+.  error
+.endif
+
+# An empty list is split into a single empty word.
+# The dirname of this empty word is ".".
+.if ${:U :H} != "."
+.  error
+.endif
+
+all: .PHONY



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

2022-06-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 12 15:03:27 UTC 2022

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

Log Message:
tests/make: make test for null bytes in .for loop more readable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-null.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

2022-06-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 12 15:03:27 UTC 2022

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

Log Message:
tests/make: make test for null bytes in .for loop more readable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-null.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-null.mk
diff -u src/usr.bin/make/unit-tests/directive-for-null.mk:1.2 src/usr.bin/make/unit-tests/directive-for-null.mk:1.3
--- src/usr.bin/make/unit-tests/directive-for-null.mk:1.2	Sun May  8 06:51:27 2022
+++ src/usr.bin/make/unit-tests/directive-for-null.mk	Sun Jun 12 15:03:27 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-null.mk,v 1.2 2022/05/08 06:51:27 rillig Exp $
+# $NetBSD: directive-for-null.mk,v 1.3 2022/06/12 15:03:27 rillig Exp $
 #
 # Test for parsing a .for loop that accidentally contains a null byte.
 #
@@ -15,5 +15,9 @@
 # line that contains a null byte is line 2.
 
 all: .PHONY
-	@printf '%s\n' '.for i in 1 2 3' 'VAR=value' '.endfor' | tr 'l' '\0' \
+	@printf '%s\n' \
+	'.for i in 1 2 3' \
+	'VAR=value' \
+	'.endfor' \
+	| tr 'l' '\0' \
 	| ${MAKE} -f -



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

2022-06-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 12 14:27:06 UTC 2022

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

Log Message:
tests/make: demonstrate what happens for 'make -DVAR=value'


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-define.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-define.mk
diff -u src/usr.bin/make/unit-tests/opt-define.mk:1.3 src/usr.bin/make/unit-tests/opt-define.mk:1.4
--- src/usr.bin/make/unit-tests/opt-define.mk:1.3	Sun Jan 23 16:09:38 2022
+++ src/usr.bin/make/unit-tests/opt-define.mk	Sun Jun 12 14:27:06 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-define.mk,v 1.3 2022/01/23 16:09:38 rillig Exp $
+# $NetBSD: opt-define.mk,v 1.4 2022/06/12 14:27:06 rillig Exp $
 #
 # Tests for the -D command line option, which defines global variables to the
 # value 1, like in the C preprocessor.
@@ -19,10 +19,22 @@ VAR=		overwritten
 .endif
 
 # The variable can be undefined.  If the variable had been defined in the
-# "Internal" scope instead, undefining it would have no effect.
+# "Internal" or in the "Command" scope instead, undefining it would have no
+# effect.
 .undef VAR
 .if defined(VAR)
 .  error
 .endif
 
+# The C preprocessor allows to define a macro with a specific value.  Make
+# behaves differently, it defines a variable with the name 'VAR=value' and the
+# value 1.
+.MAKEFLAGS: -DVAR=value
+.if defined(VAR)
+.  error
+.endif
+.if ${VAR=value} != "1"
+.  error
+.endif
+
 all: .PHONY



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

2022-06-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 12 14:27:06 UTC 2022

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

Log Message:
tests/make: demonstrate what happens for 'make -DVAR=value'


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-define.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

2022-06-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 11 09:15:49 UTC 2022

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

Log Message:
tests/make: test edge cases in pattern matching


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.10 -r1.11 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

2022-06-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 11 09:15:49 UTC 2022

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

Log Message:
tests/make: test edge cases in pattern matching


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.10 -r1.11 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.6 src/usr.bin/make/unit-tests/varmod-match.exp:1.7
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.6	Sat Jun 11 07:54:25 2022
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Jun 11 09:15:49 2022
@@ -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 151: Unknown modifier "]"
-make: "varmod-match.mk" line 151: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 157: Unknown modifier "]"
+make: "varmod-match.mk" line 157: 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.10 src/usr.bin/make/unit-tests/varmod-match.mk:1.11
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.10	Sat Jun 11 07:54:25 2022
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sat Jun 11 09:15:49 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.10 2022/06/11 07:54:25 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.11 2022/06/11 09:15:49 rillig Exp $
 #
 # Tests for the :M variable modifier, which filters words that match the
 # given pattern.
@@ -130,6 +130,12 @@ ${:U*}=		asterisk
 .  error
 .endif
 
+#	[\]	matches a single backslash
+WORDS=		a\b a[\]b ab
+.if ${WORDS:Ma[\]b} != "a\\b"
+.  error
+.endif
+
 #	:	terminates the pattern
 .if ${ A * :L:M:} != ""
 .  error
@@ -156,26 +162,95 @@ ${:U*}=		asterisk
 
 #	[\]	matches exactly a backslash; no escaping takes place in
 #		character ranges
-# Without the 'a' in the below expressions, the backslash would end a word and
-# thus influence how the string is split into words.
-.if ${ ${:U\\a} ${:Ua} :L:M[\]a} != "\\a"
+# Without the 'a' in the below words, the backslash would end a word and thus
+# influence how the string is split into words.
+WORDS=		1\a 2\\a
+.if ${WORDS:M?[\]a} != "1\\a"
+.  error
+.endif
+
+#	[[-]]	May look like it would match a single '[', '\' or ']', but
+#		the inner ']' has two roles: it is the upper bound of the
+#		character range as well as the closing character of the
+#		character list.  The outer ']' is just a regular character.
+WORDS=		[ ] [] \] ]]
+.if ${WORDS:M[[-]]} != "[] \\] ]]"
+.  error
+.endif
+
+#	[b[-]a]
+#		Same as for '[[-]]': the character list stops at the first
+#		']', and the 'a]' is treated as a literal string.
+WORDS=		[a \a ]a []a \]a ]]a [a] \a] ]a] ba]
+.if ${WORDS:M[b[-]a]} != "[a] \\a] ]a] ba]"
+.  error
+.endif
+
+#	[-]	Matches a single '-' since the '-' only becomes part of a
+#		character range if it is preceded and followed by another
+#		character.
+WORDS=		- -]
+.if ${WORDS:M[-]} != "-"
+.  error
+.endif
+
+#	[	Incomplete empty character list, never matches.
+WORDS=		a a[
+.if ${WORDS:Ma[} != ""
+.  error
+.endif
+
+#	[^	Incomplete negated empty character list, matches any single
+#		character.
+WORDS=		a a[ aX
+.if ${WORDS:Ma[^} != "a[ aX"
 .  error
 .endif
 
-#.MAKEFLAGS: -dcv
-#
-# Incomplete patterns:
-#	[	matches TODO
-#	[x	matches TODO
-#	[^	matches TODO
-#	[-	matches TODO
-#	[xy	matches TODO
-#	[^x	matches TODO
-#	[\	matches TODO
-#
-#	[x-	matches exactly 'x', doesn't match 'x-'
-#	[^x-	matches TODO
-#	\	matches never
+#	[-x1-3	Incomplete character list, matches those elements that can be
+#		parsed without lookahead.
+WORDS=		- + x xx 0 1 2 3 4 [x1-3
+.if ${WORDS:M[-x1-3} != "- x 1 2 3"
+.  error
+.endif
+
+#	[^-x1-3
+#		Incomplete negated character list, matches any character
+#		except those elements that can be parsed without lookahead.
+WORDS=		- + x xx 0 1 2 3 4 [x1-3
+.if ${WORDS:M[^-x1-3} != "+ 0 4"
+.  error
+.endif
+
+#	[\	Incomplete character list containing a single '\'.
+#
+#		A word can only end with a backslash if the preceding
+#		character is a backslash as well; in all other cases the final
+#		backslash would escape the following space, making the space
+#		part of the word.  Only the very last word of a string can be
+#		'\', as there is no following space that could be escaped.
+WORDS=		\\ \a ${:Ux\\}
+.if ${WORDS:M?[\]} != " x\\"
+.  error
+.endif
+
+#	[x-	Incomplete character list containing an incomplete character
+#		range, 

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

2022-06-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 11 07:54:25 UTC 2022

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

Log Message:
tests/make: demonstrate another pathological pattern match


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.9 -r1.10 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.5 src/usr.bin/make/unit-tests/varmod-match.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.5	Thu Mar  3 20:20:23 2022
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Sat Jun 11 07:54:25 2022
@@ -5,12 +5,13 @@ Comparing "five six seven" != "five six 
 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 146: Unknown modifier "]"
-make: "varmod-match.mk" line 146: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+make: "varmod-match.mk" line 151: Unknown modifier "]"
+make: "varmod-match.mk" line 151: 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.9 src/usr.bin/make/unit-tests/varmod-match.mk:1.10
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.9	Sun May  8 06:51:27 2022
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Sat Jun 11 07:54:25 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.9 2022/05/08 06:51:27 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.10 2022/06/11 07:54:25 rillig Exp $
 #
 # Tests for the :M variable modifier, which filters words that match the
 # given pattern.
@@ -28,11 +28,16 @@ NUMBERS=	One Two Three Four five six sev
 .  error
 .endif
 
-# Before 2020-06-13, this expression took quite a long time in Str_Match,
-# calling itself 601080390 times for 16 asterisks.
+# Before 2020-06-13, this expression called Str_Match 601,080,390 times.
+# Since 2020-06-13, this expression calls Str_Match 1 time.
 .if ${:U:Mb}
 .endif
 
+# As of 2022-06-11, this expression calls Str_Match 5,242,223 times.
+# Adding another '*?' to the pattern calls Str_Match 41,261,143 times.
+.if ${:U..b:M*?*?*?*?*?a}
+.endif
+
 # To match a dollar sign in a word, double it.
 #
 # This is different from the :S and :C variable modifiers, where a '$'



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

2022-06-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jun 11 07:54:25 UTC 2022

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

Log Message:
tests/make: demonstrate another pathological pattern match


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.9 -r1.10 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

2022-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 10 21:28:50 UTC 2022

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

Log Message:
tests/make: reword comment in Makefile to be more specific


To generate a diff of this commit:
cvs rdiff -u -r1.317 -r1.318 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

2022-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 10 21:28:50 UTC 2022

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

Log Message:
tests/make: reword comment in Makefile to be more specific


To generate a diff of this commit:
cvs rdiff -u -r1.317 -r1.318 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.317 src/usr.bin/make/unit-tests/Makefile:1.318
--- src/usr.bin/make/unit-tests/Makefile:1.317	Thu Jun  2 07:34:39 2022
+++ src/usr.bin/make/unit-tests/Makefile	Fri Jun 10 21:28:50 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.317 2022/06/02 07:34:39 skrll Exp $
+# $NetBSD: Makefile,v 1.318 2022/06/10 21:28:50 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -692,7 +692,7 @@ LIMIT_RESOURCES?=	:
 	echo $$status > ${.TARGET:R}.status
 	@mv ${.TARGET}.tmp ${.TARGET}
 
-# Postprocess the test output so that the results can be compared.
+# Postprocess the test output to make the output platform-independent.
 #
 # always pretend .MAKE was called 'make'
 _SED_CMDS+=	-e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'



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

2022-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 10 18:58:07 UTC 2022

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

Log Message:
tests/make: demonstrate spaces and '#' in command line arguments


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline.exp \
src/usr.bin/make/unit-tests/cmdline.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/cmdline.exp
diff -u src/usr.bin/make/unit-tests/cmdline.exp:1.3 src/usr.bin/make/unit-tests/cmdline.exp:1.4
--- src/usr.bin/make/unit-tests/cmdline.exp:1.3	Wed Feb  9 18:54:19 2022
+++ src/usr.bin/make/unit-tests/cmdline.exp	Fri Jun 10 18:58:07 2022
@@ -2,4 +2,7 @@ makeobjdir-direct:
 show-objdir: /6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
 makeobjdir-indirect:
 show-objdir: /a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
+space-and-comment:
+value # no comment $
+value # no comment $
 exit status 0
Index: src/usr.bin/make/unit-tests/cmdline.mk
diff -u src/usr.bin/make/unit-tests/cmdline.mk:1.3 src/usr.bin/make/unit-tests/cmdline.mk:1.4
--- src/usr.bin/make/unit-tests/cmdline.mk:1.3	Sat Feb  6 18:26:03 2021
+++ src/usr.bin/make/unit-tests/cmdline.mk	Fri Jun 10 18:58:07 2022
@@ -1,4 +1,4 @@
-# $NetBSD: cmdline.mk,v 1.3 2021/02/06 18:26:03 sjg Exp $
+# $NetBSD: cmdline.mk,v 1.4 2022/06/10 18:58:07 rillig Exp $
 #
 # Tests for command line parsing and related special variables.
 
@@ -11,6 +11,7 @@ DIR12=		${TMPBASE}/${SUB1}/${SUB2}
 
 all: prepare-dirs
 all: makeobjdir-direct makeobjdir-indirect
+all: space-and-comment
 
 prepare-dirs:
 	@rm -rf ${DIR2} ${DIR12}
@@ -34,3 +35,24 @@ makeobjdir-indirect:
 
 show-objdir:
 	@echo $@: ${.OBJDIR:Q}
+
+
+# Variable assignments in the command line are handled differently from
+# variable assignments in makefiles.  In the command line, trailing whitespace
+# is preserved, and the '#' does not start a comment.  This is because the
+# low-level parsing from ParseRawLine does not take place.
+#
+# Preserving '#' and trailing whitespace has the benefit that when passing
+# such values to sub-makes via MAKEFLAGS, no special encoding is needed.
+# Leading whitespace in the variable value is discarded though, which makes
+# the behavior inconsistent.
+space-and-comment: .PHONY
+	@echo $@:
+
+	@env -i \
+	${MAKE} -r -f /dev/null ' VAR= value # no comment ' -v VAR \
+	| sed 's,$$,$$,'
+
+	@env -i MAKEFLAGS="' VAR= value # no comment '" \
+	${MAKE} -r -f /dev/null -v VAR \
+	| sed 's,$$,$$,'



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

2022-06-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jun 10 18:58:07 UTC 2022

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

Log Message:
tests/make: demonstrate spaces and '#' in command line arguments


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline.exp \
src/usr.bin/make/unit-tests/cmdline.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

2022-06-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun  2 07:34:40 UTC 2022

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

Log Message:
Increase the resource limit so these tests pass on hppa.

LGTM from Roland


To generate a diff of this commit:
cvs rdiff -u -r1.316 -r1.317 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.316 src/usr.bin/make/unit-tests/Makefile:1.317
--- src/usr.bin/make/unit-tests/Makefile:1.316	Mon May 23 22:33:56 2022
+++ src/usr.bin/make/unit-tests/Makefile	Thu Jun  2 07:34:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.316 2022/05/23 22:33:56 rillig Exp $
+# $NetBSD: Makefile,v 1.317 2022/06/02 07:34:39 skrll Exp $
 #
 # Unit tests for make(1)
 #
@@ -670,7 +670,7 @@ MAKE_TEST_ENV+=	MALLOC_CONF="junk:true"	
 MAKE_TEST_ENV+= TMPDIR=${TMPDIR}
 
 .if ${.MAKE.OS} == "NetBSD"
-LIMIT_RESOURCES?=	ulimit -v 20
+LIMIT_RESOURCES?=	ulimit -v 30
 .endif
 LIMIT_RESOURCES?=	:
 



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

2022-06-02 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jun  2 07:34:40 UTC 2022

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

Log Message:
Increase the resource limit so these tests pass on hppa.

LGTM from Roland


To generate a diff of this commit:
cvs rdiff -u -r1.316 -r1.317 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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 10:14:41 UTC 2022

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

Log Message:
tests/make: explain that assignments ignore leading spaces


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-quote-dollar.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-quote-dollar.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-quote-dollar.exp
diff -u src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.2 src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.2	Sat Jan 22 17:10:51 2022
+++ src/usr.bin/make/unit-tests/varmod-quote-dollar.exp	Sun May  8 10:14:40 2022
@@ -1,2 +1,4 @@
 !"#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
+!"#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
+ !"#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-quote-dollar.mk
diff -u src/usr.bin/make/unit-tests/varmod-quote-dollar.mk:1.3 src/usr.bin/make/unit-tests/varmod-quote-dollar.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-quote-dollar.mk:1.3	Sat Jan 22 17:10:51 2022
+++ src/usr.bin/make/unit-tests/varmod-quote-dollar.mk	Sun May  8 10:14:40 2022
@@ -1,10 +1,17 @@
-# $NetBSD: varmod-quote-dollar.mk,v 1.3 2022/01/22 17:10:51 rillig Exp $
+# $NetBSD: varmod-quote-dollar.mk,v 1.4 2022/05/08 10:14:40 rillig Exp $
 #
 # Tests for the :q variable modifier, which quotes the string for the shell
 # and doubles dollar signs, to prevent them from being interpreted by a
 # child process of make.
 
+# The newline and space characters at the beginning of this string are passed
+# to the child make.  When the child make parses the variable assignment, it
+# discards the leading space characters.
 ASCII_CHARS=	${.newline} !"\#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
 
 all:
-	@${MAKE} -r -f /dev/null CHARS=${ASCII_CHARS:q} -V CHARS
+	@${MAKE} -r -f /dev/null \
+	CHARS=${ASCII_CHARS:q} \
+	TWICE=${ASCII_CHARS:q}${ASCII_CHARS:q} \
+	-V CHARS \
+	-V TWICE



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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 10:14:41 UTC 2022

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

Log Message:
tests/make: explain that assignments ignore leading spaces


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-quote-dollar.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-quote-dollar.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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 07:27:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: hanoi-include.mk opt-version.mk
opt-x-reduce-exported.exp opt-x-reduce-exported.mk

Log Message:
tests/make: add test for option '-X', clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/hanoi-include.mk \
src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-version.mk \
src/usr.bin/make/unit-tests/opt-x-reduce-exported.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/hanoi-include.mk
diff -u src/usr.bin/make/unit-tests/hanoi-include.mk:1.2 src/usr.bin/make/unit-tests/hanoi-include.mk:1.3
--- src/usr.bin/make/unit-tests/hanoi-include.mk:1.2	Sat Jan  8 22:13:43 2022
+++ src/usr.bin/make/unit-tests/hanoi-include.mk	Sun May  8 07:27:50 2022
@@ -1,19 +1,20 @@
-# $NetBSD: hanoi-include.mk,v 1.2 2022/01/08 22:13:43 rillig Exp $
+# $NetBSD: hanoi-include.mk,v 1.3 2022/05/08 07:27:50 rillig Exp $
 #
-# Implements the Towers of Hanoi puzzle, thereby demonstrating a bunch of
-# more or less useful programming techniques:
+# Implements the Towers of Hanoi puzzle, demonstrating a bunch of more or less
+# useful programming techniques:
 #
-# * default assignment using the ?= assignment operator
-# * including the same file recursively (rather unusual)
-# * extracting the current value of a variable using the .for loop
-# * using shell commands for calculations since make is a text processor
-# * using the :: dependency operator for adding commands to a target
-# * on-the-fly variable assignment expressions using the ::= modifier
+#	* default assignment using the ?= assignment operator
+#	* including the same file recursively (rather unusual)
+#	* extracting the current value of a variable using the .for loop
+#	* using shell commands for calculations since make is a text processor
+#	* using the :: dependency operator for adding commands to a target
+#	* on-the-fly variable assignment expressions using the ::= modifier
 #
 # usage:
-#	env N=3 make -f hanoi-include.mk
-# endless loop:
-#	make -f hanoi-include.mk N=3
+#	env N=3 make -r -f hanoi-include.mk
+#
+# endless loop, since command line variables cannot be overridden:
+#	make -r -f hanoi-include.mk N=3
 
 N?=	5			# Move this number of disks ...
 FROM?=	A			# ... from this stack ...
Index: src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk
diff -u src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.2 src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.3
--- src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk	Sun May  8 07:27:50 2022
@@ -1,8 +1,20 @@
-# $NetBSD: opt-x-reduce-exported.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: opt-x-reduce-exported.mk,v 1.3 2022/05/08 07:27:50 rillig Exp $
 #
-# Tests for the -x command line option.
+# Tests for the -X command line option, which prevents variables passed on the
+# command line from being exported to the environment of child commands.
 
-# TODO: Implementation
+# The variable 'BEFORE' is exported, the variable 'AFTER' isn't.
+.MAKEFLAGS: BEFORE=before -X AFTER=after
 
-all:
-	@:;
+all: .PHONY ordinary submake
+
+ordinary: .PHONY
+	@echo 'ordinary:'
+	@env | sort | grep -e '^BEFORE' -e '^AFTER'
+
+submake: .PHONY
+	@echo 'submake:'
+	@${MAKE} -r -f ${MAKEFILE} show-env
+
+show-env: .PHONY
+	@env | sort | grep -e '^BEFORE' -e '^AFTER'

Index: src/usr.bin/make/unit-tests/opt-version.mk
diff -u src/usr.bin/make/unit-tests/opt-version.mk:1.1 src/usr.bin/make/unit-tests/opt-version.mk:1.2
--- src/usr.bin/make/unit-tests/opt-version.mk:1.1	Thu Dec 23 11:05:59 2021
+++ src/usr.bin/make/unit-tests/opt-version.mk	Sun May  8 07:27:50 2022
@@ -1,8 +1,8 @@
-# $NetBSD: opt-version.mk,v 1.1 2021/12/23 11:05:59 rillig Exp $
+# $NetBSD: opt-version.mk,v 1.2 2022/05/08 07:27:50 rillig Exp $
 #
-# Tests for the command line option '--version', which outputs the version
-# number of make.  NetBSD's make does not have a version number, but the bmake
-# distribution created from it has.
+# Tests for the command line option '--version', which may be expected to
+# output the version number of make.  NetBSD's make does not have a version
+# number, but the bmake distribution created from it has.
 
 # As of 2021-12-23, the output is a single empty line since the '--' does not
 # end the command line options.  Command line parsing then continues as if
Index: src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp
diff -u src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.1 src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.2
--- src/usr.bin/make/unit-tests/opt-x-reduce-exported.exp:1.1	Sun Aug 16 12:07:51 2020
+++ 

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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 07:27:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: hanoi-include.mk opt-version.mk
opt-x-reduce-exported.exp opt-x-reduce-exported.mk

Log Message:
tests/make: add test for option '-X', clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/hanoi-include.mk \
src/usr.bin/make/unit-tests/opt-x-reduce-exported.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-version.mk \
src/usr.bin/make/unit-tests/opt-x-reduce-exported.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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 06:57:00 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: cond-token-string.exp cond-token-string.mk

Log Message:
tests/make: fix typo in variable name


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-string.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-token-string.exp
diff -u src/usr.bin/make/unit-tests/cond-token-string.exp:1.8 src/usr.bin/make/unit-tests/cond-token-string.exp:1.9
--- src/usr.bin/make/unit-tests/cond-token-string.exp:1.8	Sun May  8 06:51:27 2022
+++ src/usr.bin/make/unit-tests/cond-token-string.exp	Sun May  8 06:57:00 2022
@@ -13,8 +13,7 @@ CondParser_Eval: "${:Uvalue}"
 make: "cond-token-string.mk" line 68: A nonempty variable expression evaluates to true.
 CondParser_Eval: "${:U}"
 make: "cond-token-string.mk" line 76: An empty variable evaluates to false.
-CondParser_Eval: ("${VALUE}")
-make: "cond-token-string.mk" line 84: Missing argument for ".error"
+CondParser_Eval: ("${VAR}")
 CondParser_Eval: "quoted" == quoted
 Comparing "quoted" == "quoted"
 make: Fatal errors encountered -- cannot continue

Index: src/usr.bin/make/unit-tests/cond-token-string.mk
diff -u src/usr.bin/make/unit-tests/cond-token-string.mk:1.5 src/usr.bin/make/unit-tests/cond-token-string.mk:1.6
--- src/usr.bin/make/unit-tests/cond-token-string.mk:1.5	Sun May  8 06:51:27 2022
+++ src/usr.bin/make/unit-tests/cond-token-string.mk	Sun May  8 06:57:00 2022
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-string.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
+# $NetBSD: cond-token-string.mk,v 1.6 2022/05/08 06:57:00 rillig Exp $
 #
 # Tests for quoted string literals in .if conditions.
 #
@@ -77,9 +77,11 @@
 .endif
 
 # A non-empty string evaluates to true, no matter if it's a literal string or
-# if it contains variable expressions.
+# if it contains variable expressions.  The parentheses are not necessary for
+# the parser, in this case their only purpose is to make the code harder to
+# read for humans.
 VAR=	value
-.if ("${VALUE}")
+.if ("${VAR}")
 .else
 .  error
 .endif



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

2022-05-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  8 06:57:00 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: cond-token-string.exp cond-token-string.mk

Log Message:
tests/make: fix typo in variable name


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-token-string.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

2022-05-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May  7 21:24:53 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
tests/make: document why deptgt-posix needs its own directory

As described in PR toolchain/15163, '.include ' first looks in the
current directory, using the system include path only as fallback.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-posix.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/deptgt-posix.mk
diff -u src/usr.bin/make/unit-tests/deptgt-posix.mk:1.3 src/usr.bin/make/unit-tests/deptgt-posix.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt-posix.mk:1.3	Sat May  7 12:40:40 2022
+++ src/usr.bin/make/unit-tests/deptgt-posix.mk	Sat May  7 21:24:52 2022
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-posix.mk,v 1.3 2022/05/07 12:40:40 rillig Exp $
+# $NetBSD: deptgt-posix.mk,v 1.4 2022/05/07 21:24:52 rillig Exp $
 #
 # Tests for the special target '.POSIX', which enables POSIX mode.
 #
@@ -13,7 +13,10 @@
 #
 # Implementation note: this test needs to run isolated from the usual tests
 # directory to prevent unit-tests/posix.mk from interfering with the posix.mk
-# from the system directory that this test uses.
+# from the system directory that this test uses; since at least 1997, the
+# directive '.include ' has been looking in the current directory first
+# before searching the file in the system search path, as described in
+# https://gnats.netbsd.org/15163.
 #
 # See also:
 #	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html



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

2022-05-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May  7 21:24:53 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
tests/make: document why deptgt-posix needs its own directory

As described in PR toolchain/15163, '.include ' first looks in the
current directory, using the system include path only as fallback.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-posix.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

2022-05-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May  7 12:40:40 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
tests/make: clean up comments in test for .POSIX


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-posix.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

2022-05-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat May  7 12:40:40 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
tests/make: clean up comments in test for .POSIX


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-posix.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/deptgt-posix.mk
diff -u src/usr.bin/make/unit-tests/deptgt-posix.mk:1.2 src/usr.bin/make/unit-tests/deptgt-posix.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-posix.mk:1.2	Mon Apr 18 15:59:39 2022
+++ src/usr.bin/make/unit-tests/deptgt-posix.mk	Sat May  7 12:40:40 2022
@@ -1,16 +1,19 @@
-# $NetBSD: deptgt-posix.mk,v 1.2 2022/04/18 15:59:39 sjg Exp $
+# $NetBSD: deptgt-posix.mk,v 1.3 2022/05/07 12:40:40 rillig Exp $
 #
 # Tests for the special target '.POSIX', which enables POSIX mode.
 #
-# As of 2022-04-18, this only means that the variable '%POSIX' is defined and
-# that the variables and rules specified by POSIX replace the default ones.
-# This is done by loading , if available.  That file is not included
-# in NetBSD, but only in the bmake distribution.  As of 2022-04-18, POSIX
-# support is not complete.
+# As of 2022-04-18, when parsing the dependency line '.POSIX', the variable
+# '%POSIX' is defined and  is included, if it exists.  Other than
+# that, POSIX support is still incomplete, the exact set of supported features
+# needs to be cross-checked with the POSIX specification.
 #
-# Implementation node: this test needs to be isolated from the usual test
-# to prevent unit-tests/posix.mk from interfering with the posix.mk from the
-# system directory that this test uses.
+# At the point of '.POSIX:',  has been loaded already, unless the
+# option '-r' was given.  This means that an implementation of  must
+# work both with and without the system rules from  being in effect.
+#
+# Implementation note: this test needs to run isolated from the usual tests
+# directory to prevent unit-tests/posix.mk from interfering with the posix.mk
+# from the system directory that this test uses.
 #
 # See also:
 #	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
@@ -99,7 +102,8 @@ in-first-line: .PHONY set-up-sysdir chec
 	'.POSIX:'
 
 # The only allowed lines before switching to POSIX mode are comment lines.
-# POSIX defines that empty and blank lines are called comment lines as well.
+# POSIX defines comment lines as "blank lines, empty lines, and lines with
+#  ('#') as the first character".
 all: after-comment-lines
 after-comment-lines: .PHONY set-up-sysdir check-is-posix run
 	printf '%s\n' > ${MAIN_MK} \



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

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 15:59:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is

Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-posix.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/deptgt-posix.mk
diff -u src/usr.bin/make/unit-tests/deptgt-posix.mk:1.1 src/usr.bin/make/unit-tests/deptgt-posix.mk:1.2
--- src/usr.bin/make/unit-tests/deptgt-posix.mk:1.1	Mon Apr 18 15:06:28 2022
+++ src/usr.bin/make/unit-tests/deptgt-posix.mk	Mon Apr 18 15:59:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-posix.mk,v 1.1 2022/04/18 15:06:28 rillig Exp $
+# $NetBSD: deptgt-posix.mk,v 1.2 2022/04/18 15:59:39 sjg Exp $
 #
 # Tests for the special target '.POSIX', which enables POSIX mode.
 #
@@ -15,10 +15,10 @@
 # See also:
 #	https://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html
 
-TMPDIR?=	/tmp/make.test.deptgt-posix
-SYSDIR=		${TMPDIR}/sysdir
-MAIN_MK=	${TMPDIR}/main.mk
-INCLUDED_MK=	${TMPDIR}/included.mk
+TESTTMP=	${TMPDIR:U/tmp}/make.test.deptgt-posix
+SYSDIR=		${TESTTMP}/sysdir
+MAIN_MK=	${TESTTMP}/main.mk
+INCLUDED_MK=	${TESTTMP}/included.mk
 
 all: .PHONY
 .SILENT:
@@ -58,9 +58,9 @@ check-not-seen-sys-mk: .USE
 	'.endif'
 
 run: .USE
-	(cd "${TMPDIR}" && MAKEFLAGS=${MAKEFLAGS.${.TARGET}:Q} ${MAKE} \
+	(cd "${TESTTMP}" && MAKEFLAGS=${MAKEFLAGS.${.TARGET}:Q} ${MAKE} \
 	-m "${SYSDIR}" -f ${MAIN_MK:T})
-	rm -rf ${TMPDIR}
+	rm -rf ${TESTTMP}
 
 # If the main makefile has a '.for' loop as its first non-comment line, a
 # strict reading of POSIX 2018 makes the makefile non-conforming.



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

2022-04-18 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Mon Apr 18 15:59:39 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-posix.mk

Log Message:
Never 'rm -rf ${TMPDIR}' when you cannot be sure what it is

Use a safer variable for a subdir of ${TMPDIR} that we know
we can remove safely.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-posix.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

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:41:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-usebefore.mk

Log Message:
tests/make: refine documentation of test for .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/depsrc-usebefore.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/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.9
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8	Mon Apr 18 14:38:24 2022
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk	Mon Apr 18 14:41:42 2022
@@ -1,11 +1,13 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.8 2022/04/18 14:38:24 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.9 2022/04/18 14:41:42 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
 #
-# If a target depends on several .USE or .USEBEFORE targets, the commands get
-# appended in declaration order.  For .USE targets, this is the expected
-# order, for .USEBEFORE targets the order is somewhat reversed.
+# If a target depends on several .USE or .USEBEFORE nodes, the commands get
+# appended or prepended in declaration order.  For .USE nodes, this is the
+# expected order, for .USEBEFORE nodes the order is somewhat reversed, and for
+# .USE or .USEBEFORE nodes that depend on other .USE or .USEBEFORE nodes, it
+# gets even more complicated.
 #
 # See also:
 #	.USE



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

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:41:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-usebefore.mk

Log Message:
tests/make: refine documentation of test for .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/depsrc-usebefore.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

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:38:24 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-use.exp depsrc-use.mk
depsrc-usebefore.exp depsrc-usebefore.mk

Log Message:
tests/make: extend tests for .USE and .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-use.exp \
src/usr.bin/make/unit-tests/depsrc-usebefore.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.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/depsrc-use.exp
diff -u src/usr.bin/make/unit-tests/depsrc-use.exp:1.3 src/usr.bin/make/unit-tests/depsrc-use.exp:1.4
--- src/usr.bin/make/unit-tests/depsrc-use.exp:1.3	Sat Aug 22 12:30:57 2020
+++ src/usr.bin/make/unit-tests/depsrc-use.exp	Mon Apr 18 14:38:24 2022
@@ -2,5 +2,9 @@ first 1
 first 2
 second 1
 second 2
+first-first 1
+first-first 2
+first-second 1
+first-second 2
 directly
 exit status 0
Index: src/usr.bin/make/unit-tests/depsrc-usebefore.exp
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.3 src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.4
--- src/usr.bin/make/unit-tests/depsrc-usebefore.exp:1.3	Sat Aug 22 11:53:18 2020
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.exp	Mon Apr 18 14:38:24 2022
@@ -1,6 +1,42 @@
-first 1
-first 2
-second 1
-second 2
-directly
+after-2-before-2 1
+after-2-before-2 2
+after-2-before-1 1
+after-2-before-1 2
+after-1-before-2 1
+after-1-before-2 2
+after-1-before-1 1
+after-1-before-1 2
+before-2-before-2 1
+before-2-before-2 2
+before-2-before-1 1
+before-2-before-1 2
+before-1-before-2 1
+before-1-before-2 2
+before-1-before-1 1
+before-1-before-1 2
+before-2 1
+before-2 2
+before-1 1
+before-1 2
+after-1 1
+after-1 2
+after-2 1
+after-2 2
+before-1-after-1 1
+before-1-after-1 2
+before-1-after-2 1
+before-1-after-2 2
+before-2-after-1 1
+before-2-after-1 2
+before-2-after-2 1
+before-2-after-2 2
+after-1-after-1 1
+after-1-after-1 2
+after-1-after-2 1
+after-1-after-2 2
+after-2-after-1 1
+after-2-after-1 2
+after-2-after-2 1
+after-2-after-2 2
+`directly' is up to date.
 exit status 0

Index: src/usr.bin/make/unit-tests/depsrc-use.mk
diff -u src/usr.bin/make/unit-tests/depsrc-use.mk:1.5 src/usr.bin/make/unit-tests/depsrc-use.mk:1.6
--- src/usr.bin/make/unit-tests/depsrc-use.mk:1.5	Tue Dec 28 14:22:51 2021
+++ src/usr.bin/make/unit-tests/depsrc-use.mk	Mon Apr 18 14:38:24 2022
@@ -1,7 +1,11 @@
-# $NetBSD: depsrc-use.mk,v 1.5 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-use.mk,v 1.6 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USE in dependency declarations,
 # which allows to append common commands to other targets.
+#
+# See also:
+#	.USEBEFORE
+#	depsrc-usebefore.mk
 
 # Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
 # regarded as a candidate for the main target.  On the other hand, a .USE
@@ -10,9 +14,15 @@ not-a-main-candidate: .USE
 
 all: action directly
 
-first: .USE
+first: .USE first-first first-second
 	@echo first 1		# Using ${.TARGET} here would expand to "action"
 	@echo first 2
+first-first: .USE
+	@echo first-first 1
+	@echo first-first 2
+first-second: .USE
+	@echo first-second 1
+	@echo first-second 2
 
 second: .USE
 	@echo second 1
@@ -22,7 +32,7 @@ second: .USE
 # This may happen as the result of expanding a .for loop.
 empty: .USE
 
-# It's possible but uncommon to directly make a .USEBEFORE target.
+# It's possible but uncommon to directly make a .USE target.
 directly: .USE
 	@echo directly
 

Index: src/usr.bin/make/unit-tests/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.7 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.8
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.7	Tue Dec 28 14:22:51 2021
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk	Mon Apr 18 14:38:24 2022
@@ -1,8 +1,12 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.7 2021/12/28 14:22:51 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.8 2022/04/18 14:38:24 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
 #
+# If a target depends on several .USE or .USEBEFORE targets, the commands get
+# appended in declaration order.  For .USE targets, this is the expected
+# order, for .USEBEFORE targets the order is somewhat reversed.
+#
 # See also:
 #	.USE
 #	depsrc-use.mk
@@ -12,22 +16,98 @@
 # target was not.
 not-a-main-candidate: .USEBEFORE
 
-all: action directly
-
-first: .USEBEFORE
-	@echo first 1		# Using ${.TARGET} here would expand to "action"
-	@echo first 2		# Using ${.TARGET} here would expand to "action"
-
-second: .USEBEFORE
-	@echo second 1
-	@echo second 2
+all:
+	@${MAKE} -r -f ${MAKEFILE} ordering
+	@${MAKE} -r -f 

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

2022-04-18 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr 18 14:38:24 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-use.exp depsrc-use.mk
depsrc-usebefore.exp depsrc-usebefore.mk

Log Message:
tests/make: extend tests for .USE and .USEBEFORE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/depsrc-use.exp \
src/usr.bin/make/unit-tests/depsrc-usebefore.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/depsrc-usebefore.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

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 23:03:47 UTC 2022

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

Log Message:
tests/make: test .undef for exported global variables


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.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-undef.mk
diff -u src/usr.bin/make/unit-tests/directive-undef.mk:1.10 src/usr.bin/make/unit-tests/directive-undef.mk:1.11
--- src/usr.bin/make/unit-tests/directive-undef.mk:1.10	Tue Feb 16 18:02:19 2021
+++ src/usr.bin/make/unit-tests/directive-undef.mk	Fri Mar 25 23:03:47 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-undef.mk,v 1.10 2021/02/16 18:02:19 rillig Exp $
+# $NetBSD: directive-undef.mk,v 1.11 2022/03/25 23:03:47 rillig Exp $
 #
 # Tests for the .undef directive.
 #
@@ -43,11 +43,11 @@
 3=		3
 ${:U1 2 3}=	one two three
 VARNAMES=	1 2 3
-.undef ${VARNAMES}		# undefines the variable "1 2 3"
-.if !defined(${:U1 2 3})
+.undef ${VARNAMES}		# undefines the variables "1", "2" and "3"
+.if ${${:U1 2 3}} != "one two three"	# still there
 .  error
 .endif
-.if ${1:U_}${2:U_}${3:U_} != "___"	# these are still defined
+.if ${1:U_}${2:U_}${3:U_} != "___"	# these have been undefined
 .  error
 .endif
 
@@ -104,4 +104,30 @@ UT_EXPORTED=	exported-value
 .endif
 
 
+# When an exported variable is undefined, the variable is removed both from
+# the global scope as well as from the environment.
+DIRECT=		direct
+INDIRECT=	in-${DIRECT}
+.export DIRECT INDIRECT
+.if ${DIRECT} != "direct"
+.  error
+.endif
+.if ${INDIRECT} != "in-direct"
+.  error
+.endif
+
+# Deletes the variables from the global scope and also from the environment.
+# This applies to both variables, even though 'INDIRECT' is not actually
+# exported yet since it refers to another variable.
+.undef DIRECT			# Separate '.undef' directives,
+.undef INDIRECT			# for backwards compatibility.
+
+.if ${DIRECT:Uundefined} != "undefined"
+.  error
+.endif
+.if ${INDIRECT:Uundefined} != "undefined"
+.  error
+.endif
+
+
 all:



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

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 23:03:47 UTC 2022

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

Log Message:
tests/make: test .undef for exported global variables


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.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

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 22:38:39 UTC 2022

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

Log Message:
tests/make: suppress -DCLEANUP output in test deptgt-phony


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 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.309 src/usr.bin/make/unit-tests/Makefile:1.310
--- src/usr.bin/make/unit-tests/Makefile:1.309	Sat Feb 12 13:17:57 2022
+++ src/usr.bin/make/unit-tests/Makefile	Fri Mar 25 22:38:39 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.309 2022/02/12 13:17:57 rillig Exp $
+# $NetBSD: Makefile,v 1.310 2022/03/25 22:38:39 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -485,9 +485,8 @@ FLAGS.jobs-error-nested-make=	# none, es
 FLAGS.varname-empty=		-dv '$${:U}=cmdline-u' '=cmdline-plain'
 
 # Some tests need extra postprocessing.
-SED_CMDS.dir=		${:D remove output from -DCLEANUP mode }
-SED_CMDS.dir+=		-e '/^OpenDirs_Done:/d'
-SED_CMDS.dir+=		-e '/^CachedDir /d'
+SED_CMDS.deptgt-phony=	${STD_SED_CMDS.dd}
+SED_CMDS.dir=		${STD_SED_CMDS.dd}
 SED_CMDS.export=	-e '/^[^=_A-Za-z0-9]*=/d'
 SED_CMDS.export-all=	${SED_CMDS.export}
 SED_CMDS.export-env=	${SED_CMDS.export}
@@ -552,6 +551,11 @@ unexport-env.rawout: export.mk
 
 # Some standard sed commands, to be used in the SED_CMDS above.
 
+# In tests that use the debugging option -dd, ignore debugging output that is
+# only logged in -DCLEANUP mode.
+STD_SED_CMDS.dd=		-e '/^OpenDirs_Done:/d'
+STD_SED_CMDS.dd+=		-e '/^CachedDir /d'
+
 # Omit details such as process IDs from the output of the -dg1 option.
 STD_SED_CMDS.dg1=	-e 's,${.CURDIR}$$,,'
 STD_SED_CMDS.dg1+=	-e 's,  ${DEFSYSPATH:U/usr/share/mk}$$,  ,'



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

2022-03-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 25 22:38:39 UTC 2022

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

Log Message:
tests/make: suppress -DCLEANUP output in test deptgt-phony


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 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

2022-03-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Mar  3 20:20:23 UTC 2022

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

Log Message:
tests/make: add more comprehensive tests for ':M' and ':N'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.6 -r1.7 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.4 src/usr.bin/make/unit-tests/varmod-match.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-match.exp:1.4	Thu Mar  3 19:36:35 2022
+++ src/usr.bin/make/unit-tests/varmod-match.exp	Thu Mar  3 20:20:23 2022
@@ -9,4 +9,8 @@ CondParser_Eval: ${:Ua \$ sign:M*$$*} !=
 Comparing "$" != "$"
 CondParser_Eval: ${:Ua \$ sign any-asterisk:M*\$*} != "any-asterisk"
 Comparing "any-asterisk" != "any-asterisk"
-exit status 0
+make: "varmod-match.mk" line 146: Unknown modifier "]"
+make: "varmod-match.mk" line 146: 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.6 src/usr.bin/make/unit-tests/varmod-match.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-match.mk:1.6	Sun Nov 15 18:33:41 2020
+++ src/usr.bin/make/unit-tests/varmod-match.mk	Thu Mar  3 20:20:23 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match.mk,v 1.6 2020/11/15 18:33:41 rillig Exp $
+# $NetBSD: varmod-match.mk,v 1.7 2022/03/03 20:20:23 rillig Exp $
 #
 # Tests for the :M variable modifier, which filters words that match the
 # given pattern.
@@ -56,5 +56,131 @@ ${:U*}=		asterisk
 # TODO: ${VAR:M${UNBALANCED}}
 # TODO: ${VAR:M${:U(((\}\}\}}}
 
-all:
-	@:;
+.MAKEFLAGS: -d0
+
+# Special characters:
+#	*	matches 0 or more arbitrary characters
+#	?	matches a single arbitrary character
+#	\	starts an escape sequence, only outside ranges
+#	[	starts a set for matching a single character
+#	]	ends a set for matching a single character
+#	-	in a set, forms a range of characters
+#	^	as the first character in a set, negates the set
+#	(	during parsing of the pattern, starts a nesting level
+#	)	during parsing of the pattern, ends a nesting level
+#	{	during parsing of the pattern, starts a nesting level
+#	}	during parsing of the pattern, ends a nesting level
+#	:	during parsing of the pattern, finishes the pattern
+#	$	during parsing of the pattern, starts a nested expression
+#	#	in a line except a shell command, starts a comment
+#
+# Pattern parts:
+#	*	matches 0 or more arbitrary characters
+#	?	matches exactly 1 arbitrary character
+#	\x	matches exactly the character 'x'
+#	[...]	matches exactly 1 character from the set
+#	[^...]	matches exactly 1 character outside the set
+#	[a-z]	matches exactly 1 character from the range 'a' to 'z'
+#
+
+#	[]	matches never
+.if ${ ab a[]b a[b a b :L:M[]} != ""
+.  error
+.endif
+
+#	a[]b	matches never
+.if ${ ab a[]b a[b a b [ ] :L:Ma[]b} != ""
+.  error
+.endif
+
+#	[^]	matches exactly 1 arbitrary character
+.if ${ ab a[]b a[b a b [ ] :L:M[^]} != "a b [ ]"
+.  error
+.endif
+
+#	a[^]b	matches 'a', then exactly 1 arbitrary character, then 'b'
+.if ${ ab a[]b a[b a b :L:Ma[^]b} != "a[b"
+.  error
+.endif
+
+#	[Nn0]	matches exactly 1 character from the set 'N', 'n', '0'
+.if ${ a b N n 0 Nn0 [ ] :L:M[Nn0]} != "N n 0"
+.  error
+.endif
+
+#	[a-c]	matches exactly 1 character from the range 'a' to 'c'
+.if ${ A B C a b c d [a-c] [a] :L:M[a-c]} != "a b c"
+.  error
+.endif
+
+#	[c-a]	matches the same as [a-c]
+.if ${ A B C a b c d [a-c] [a] :L:M[c-a]} != "a b c"
+.  error
+.endif
+
+#	[^a-c67]
+#		matches a single character, except for 'a', 'b', 'c', '8' or
+#		'9'
+.if ${ A B C a b c d 5 6 7 8 [a-c] [a] :L:M[^a-c67]} != "A B C d 5 8"
+.  error
+.endif
+
+#	:	terminates the pattern
+.if ${ A * :L:M:} != ""
+.  error
+.endif
+
+#	\:	matches a colon
+.if ${ ${:U\: \:\:} :L:M\:} != ":"
+.  error
+.endif
+
+#	${:U\:}	matches a colon
+.if ${ ${:U\:} ${:U\:\:} :L:M${:U\:}} != ":"
+.  error
+.endif
+
+#	[:]	matches never since the ':' starts the next modifier
+# expect+2: Unknown modifier "]"
+# expect+1: Malformed conditional (${ ${:U\:} ${:U\:\:} :L:M[:]} != ":")
+.if ${ ${:U\:} ${:U\:\:} :L:M[:]} != ":"
+.  error
+.else
+.  error
+.endif
+
+#	[\]	matches exactly a backslash; no escaping takes place in
+#		character ranges
+# Without the 'a' in the below expressions, the backslash would end a word and
+# thus influence how the string is split into words.
+.if ${ ${:U\\a} ${:Ua} :L:M[\]a} != "\\a"
+.  error
+.endif
+
+#.MAKEFLAGS: -dcv
+#
+# Incomplete patterns:
+#	[	matches TODO
+#	[x	matches TODO
+#	[^	matches TODO
+#	[-	matches TODO
+#	[xy	matches TODO
+#	[^x	matches TODO
+#	[\	

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

2022-03-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Mar  3 20:20:23 UTC 2022

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

Log Message:
tests/make: add more comprehensive tests for ':M' and ':N'


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-match.exp
cvs rdiff -u -r1.6 -r1.7 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

2022-03-02 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Mar  2 19:32:16 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.mk meta-cmd-cmp.mk

Log Message:
Add nofilemon to meta mode tests

The unit-tests for meta mode do not depend on filemon.
Adding nofilemon to .MAKE.MODE allows these to pass on
a system that would use filemon_dev but does not have
the module loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/depsrc-meta.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/meta-cmd-cmp.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/depsrc-meta.mk
diff -u src/usr.bin/make/unit-tests/depsrc-meta.mk:1.6 src/usr.bin/make/unit-tests/depsrc-meta.mk:1.7
--- src/usr.bin/make/unit-tests/depsrc-meta.mk:1.6	Wed Jan 26 22:47:03 2022
+++ src/usr.bin/make/unit-tests/depsrc-meta.mk	Wed Mar  2 19:32:15 2022
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc-meta.mk,v 1.6 2022/01/26 22:47:03 rillig Exp $
+# $NetBSD: depsrc-meta.mk,v 1.7 2022/03/02 19:32:15 sjg Exp $
 #
 # Tests for the special source .META in dependency declarations.
 
@@ -9,7 +9,7 @@
 
 .if make(actual-test)
 .MAKEFLAGS: -dM
-.MAKE.MODE=	meta curDirOk=true
+.MAKE.MODE=	meta curDirOk=true nofilemon
 .endif
 
 actual-test: depsrc-meta-target

Index: src/usr.bin/make/unit-tests/meta-cmd-cmp.mk
diff -u src/usr.bin/make/unit-tests/meta-cmd-cmp.mk:1.5 src/usr.bin/make/unit-tests/meta-cmd-cmp.mk:1.6
--- src/usr.bin/make/unit-tests/meta-cmd-cmp.mk:1.5	Wed Feb  9 21:09:24 2022
+++ src/usr.bin/make/unit-tests/meta-cmd-cmp.mk	Wed Mar  2 19:32:15 2022
@@ -1,11 +1,11 @@
-# $NetBSD: meta-cmd-cmp.mk,v 1.5 2022/02/09 21:09:24 rillig Exp $
+# $NetBSD: meta-cmd-cmp.mk,v 1.6 2022/03/02 19:32:15 sjg Exp $
 #
 # Tests META_MODE command line comparison
 #
 
 .MAIN: all
 
-.MAKE.MODE= meta verbose silent=yes curdirok=yes
+.MAKE.MODE= meta verbose silent=yes curdirok=yes nofilemon
 tf:= .${.PARSEFILE:R}
 
 .if ${.TARGETS:Nall} == ""



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

2022-03-02 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Mar  2 19:32:16 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.mk meta-cmd-cmp.mk

Log Message:
Add nofilemon to meta mode tests

The unit-tests for meta mode do not depend on filemon.
Adding nofilemon to .MAKE.MODE allows these to pass on
a system that would use filemon_dev but does not have
the module loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/depsrc-meta.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/meta-cmd-cmp.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

2022-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 12 20:05:36 UTC 2022

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

Log Message:
tests/make: clean up comments in test for indirect -k failures

See PR#49720.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
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

2022-02-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb 12 20:05:36 UTC 2022

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

Log Message:
tests/make: clean up comments in test for indirect -k failures

See PR#49720.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
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.1 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.1	Sat Feb 12 13:17:57 2022
+++ src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk	Sat Feb 12 20:05:36 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-keep-going-indirect.mk,v 1.1 2022/02/12 13:17:57 rillig Exp $
+# $NetBSD: opt-keep-going-indirect.mk,v 1.2 2022/02/12 20:05:36 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
@@ -6,27 +6,28 @@
 #
 # History:
 #	In 1993, the exit status for the option '-k' was always 0, even if a
-#	a direct or an indirect target failed.
+#	direct or an indirect target failed.
 #
 #	Since 2000.12.30.02.05.21, the word '(continuing)' is missing in jobs
 #	mode, both for direct as well as indirect targets.
 #
 #	Since 2001.10.16.18.50.12, the exit status for a direct failure in
-#	compat mode is 1, while jobs mode and indirect failures still return
-#	exit status 0.  The number of empty lines between the various error
-#	messages differs between the modes, for no reason.
+#	compat mode is the correct 1, while jobs mode and indirect failures
+#	still return the wrong exit status 0.  The number of empty lines
+#	between the various error messages differs between the modes, for no
+#	reason.
 #
 #	At 2006.11.17.22.07.39, the exit status for direct failures in both
-#	modes and for indirect failures in jobs mode was corrected, leaving
-#	only indirect failures in compat mode wrong.  On the downside, a
-#	failed indirect target in jobs mode was no longer listed as "not
-#	remade because of errors".
-#
-#	At 2016.08.26.23.28.39, the additional empty lines for a direct
-#	failure in compat mode was removed, making it consistent with a direct
-#	failure in jobs mode.  This left only one inconsistency, in that
-#	indirect failures in jobs mode (by far the most common when building
-#	large projects) did not produce any empty line.
+#	modes and for indirect failures in jobs mode was fixed to the correct
+#	1.  The exit status for indirect failures in compat mode is still the
+#	wrong 0.  On the downside, a failed indirect target in jobs mode is no
+#	longer listed as "not remade because of errors".
+#
+#	At 2016.08.26.23.28.39, the additional empty line for a direct failure
+#	in compat mode was removed, making it consistent with a direct failure
+#	in jobs mode.  This left only one inconsistency, in that indirect
+#	failures in jobs mode (by far the most common when building large
+#	projects) did not produce any empty line.
 #
 #	Since 2020.12.07.00.53.30, the exit status is consistently 1 for
 #	failures in all 4 modes.
@@ -83,6 +84,7 @@ direct:
 # expect: exited 1
 
 # TODO: Add '(continuing)'.
+# TODO: Add 'not remade because of errors'.
 # expect: indirect jobs
 # expect: *** [direct] Error code 1
 # expect: exited 1



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

2022-02-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 11 23:44:18 UTC 2022

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

Log Message:
tests/make: reproduce filesystem lookup of .PHONY nodes

As described in PR toolchain/15164.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-phony.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-phony.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/deptgt-phony.exp
diff -u src/usr.bin/make/unit-tests/deptgt-phony.exp:1.1 src/usr.bin/make/unit-tests/deptgt-phony.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-phony.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/deptgt-phony.exp	Fri Feb 11 23:44:18 2022
@@ -1 +1,42 @@
+Expanding "depsrc-phony-pr-15164-*-wildcard"... 
+Expanding "deptgt-phony-pr-15164-*-wildcard"... 
+Searching for .depend ...
+   failed.
+Searching for .depend ...
+   /usr/share/mk ...
+   failed.
+Wildcard expanding "all"...
+Searching for all ...
+   failed.
+Found 'all' as '(not found)'
+SuffFindDeps "all"
+	No known suffix on all. Using .NULL suffix
+adding suffix rules
+Wildcard expanding "depsrc-phony-pr-15164-*-wildcard"...
+Expanding "depsrc-phony-pr-15164-*-wildcard"... 
+
+Wildcard expanding "deptgt-phony-pr-15164-*-wildcard"...
+Expanding "deptgt-phony-pr-15164-*-wildcard"... 
+
+Searching for all ...
+   failed.
+SuffFindDeps "depsrc-phony-pr-15164"
+	No valid suffix on depsrc-phony-pr-15164
+SuffFindDeps "deptgt-phony-pr-15164"
+	No valid suffix on deptgt-phony-pr-15164
+: Making depsrc-phony-pr-15164
+: Making deptgt-phony-pr-15164
+Wildcard expanding "all"...
+Searching for all ...
+   failed.
+Found 'all' as '(not found)'
+SuffFindDeps ".END"
+	No known suffix on .END. Using .NULL suffix
+adding suffix rules
+Searching for .END ...
+   failed.
+Wildcard expanding ".END"...
+Searching for .END ...
+   failed.
+Found '.END' as '(not found)'
 exit status 0

Index: src/usr.bin/make/unit-tests/deptgt-phony.mk
diff -u src/usr.bin/make/unit-tests/deptgt-phony.mk:1.2 src/usr.bin/make/unit-tests/deptgt-phony.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-phony.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/deptgt-phony.mk	Fri Feb 11 23:44:18 2022
@@ -1,8 +1,31 @@
-# $NetBSD: deptgt-phony.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: deptgt-phony.mk,v 1.3 2022/02/11 23:44:18 rillig Exp $
 #
 # Tests for the special target .PHONY in dependency declarations.
 
 # TODO: Implementation
 
 all:
-	@:;
+
+
+# https://gnats.netbsd.org/15164 describes that .PHONY targets are still
+# looked up in directories, even though .PHONY means that these targets do
+# _not_ correspond to actual files.
+#
+# expect: Expanding "depsrc-phony-pr-15164-*-wildcard"...
+# expect: Expanding "deptgt-phony-pr-15164-*-wildcard"...
+.MAKEFLAGS: -dds
+depsrc-phony-pr-15164: .PHONY
+	: Making ${.TARGET}
+depsrc-phony-pr-15164-*-wildcard: .PHONY
+	: Making ${.TARGET}
+
+.PHONY: deptgt-phony-pr-15164
+deptgt-phony-pr-15164:
+	: Making ${.TARGET}
+
+.PHONY: deptgt-phony-pr-15164-*-wildcard
+deptgt-phony-pr-15164-*-wildcard:
+	: Making ${.TARGET}
+
+all: depsrc-phony-pr-15164 depsrc-phony-pr-15164-*-wildcard
+all: deptgt-phony-pr-15164 deptgt-phony-pr-15164-*-wildcard



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

2022-02-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Feb 11 23:44:18 UTC 2022

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

Log Message:
tests/make: reproduce filesystem lookup of .PHONY nodes

As described in PR toolchain/15164.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-phony.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-phony.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

2022-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  9 21:24:29 UTC 2022

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

Log Message:
tests/make: remove redundant 'echo' from variable assignments

Before main.c 1.231 from 2014-09-09, a variable assignment using the
operator '!=' generated a warning "Couldn't read shell's output" if the
output of the command was empty.  The simplest way to suppress this
wrong warning was to add an empty 'echo' to the command.  This hack is
no longer needed.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/objdir-writable.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.306 src/usr.bin/make/unit-tests/Makefile:1.307
--- src/usr.bin/make/unit-tests/Makefile:1.306	Wed Feb  9 21:09:24 2022
+++ src/usr.bin/make/unit-tests/Makefile	Wed Feb  9 21:24:29 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.306 2022/02/09 21:09:24 rillig Exp $
+# $NetBSD: Makefile,v 1.307 2022/02/09 21:24:29 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -653,7 +653,7 @@ TMPDIR:=	/tmp/uid${.MAKE.UID}
 .endif
 # make sure it exists
 .if !exist(${TMPDIR})
-x!= echo; mkdir -p ${TMPDIR}
+_!= mkdir -p ${TMPDIR}
 .endif
 
 MAKE_TEST_ENV=	MALLOC_OPTIONS="JA"	# for jemalloc 100

Index: src/usr.bin/make/unit-tests/objdir-writable.mk
diff -u src/usr.bin/make/unit-tests/objdir-writable.mk:1.6 src/usr.bin/make/unit-tests/objdir-writable.mk:1.7
--- src/usr.bin/make/unit-tests/objdir-writable.mk:1.6	Wed Feb  9 21:09:24 2022
+++ src/usr.bin/make/unit-tests/objdir-writable.mk	Wed Feb  9 21:24:29 2022
@@ -1,4 +1,4 @@
-# $NetBSD: objdir-writable.mk,v 1.6 2022/02/09 21:09:24 rillig Exp $
+# $NetBSD: objdir-writable.mk,v 1.7 2022/02/09 21:24:29 rillig Exp $
 
 # test checking for writable objdir
 
@@ -14,7 +14,8 @@ do-objdir:
 all: no-objdir ro-objdir explicit-objdir
 
 # make it now
-x!= echo; mkdir -p ${RO_OBJDIR};  chmod 555 ${RO_OBJDIR}
+_!=	mkdir -p ${RO_OBJDIR}
+_!=	chmod 555 ${RO_OBJDIR}
 
 .END: rm-objdir
 rm-objdir:



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

2022-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  9 21:24:29 UTC 2022

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

Log Message:
tests/make: remove redundant 'echo' from variable assignments

Before main.c 1.231 from 2014-09-09, a variable assignment using the
operator '!=' generated a warning "Couldn't read shell's output" if the
output of the command was empty.  The simplest way to suppress this
wrong warning was to add an empty 'echo' to the command.  This hack is
no longer needed.


To generate a diff of this commit:
cvs rdiff -u -r1.306 -r1.307 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/objdir-writable.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

2022-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  9 18:54:19 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile cmdline.exp export.exp
objdir-writable.exp

Log Message:
tests/make: use more distinctive placeholder for TMPDIR


To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmdline.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/export.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/objdir-writable.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.303 src/usr.bin/make/unit-tests/Makefile:1.304
--- src/usr.bin/make/unit-tests/Makefile:1.303	Mon Feb  7 22:43:50 2022
+++ src/usr.bin/make/unit-tests/Makefile	Wed Feb  9 18:54:19 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.303 2022/02/07 22:43:50 rillig Exp $
+# $NetBSD: Makefile,v 1.304 2022/02/09 18:54:19 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -695,7 +695,7 @@ _SED_CMDS+=	-e '/stopped/s, /.*, unit-te
 # Allow the test files to be placed anywhere.
 _SED_CMDS+=	-e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = ,'
 _SED_CMDS+=	-e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = ,'
-_SED_CMDS+=	-e 's,${TMPDIR},TMPDIR,g'
+_SED_CMDS+=	-e 's,${TMPDIR},,g'
 # canonicalize ${.OBJDIR} and ${.CURDIR}
 .if ${.OBJDIR} != ${.CURDIR}
 # yes this is inaccurate but none of the tests expect  anywhere

Index: src/usr.bin/make/unit-tests/cmdline.exp
diff -u src/usr.bin/make/unit-tests/cmdline.exp:1.2 src/usr.bin/make/unit-tests/cmdline.exp:1.3
--- src/usr.bin/make/unit-tests/cmdline.exp:1.2	Sat Feb  6 18:26:03 2021
+++ src/usr.bin/make/unit-tests/cmdline.exp	Wed Feb  9 18:54:19 2022
@@ -1,5 +1,5 @@
 makeobjdir-direct:
-show-objdir: TMPDIR/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
+show-objdir: /6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
 makeobjdir-indirect:
-show-objdir: TMPDIR/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
+show-objdir: /a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
 exit status 0

Index: src/usr.bin/make/unit-tests/export.exp
diff -u src/usr.bin/make/unit-tests/export.exp:1.6 src/usr.bin/make/unit-tests/export.exp:1.7
--- src/usr.bin/make/unit-tests/export.exp:1.6	Sat Feb  6 18:26:03 2021
+++ src/usr.bin/make/unit-tests/export.exp	Wed Feb  9 18:54:19 2022
@@ -1,5 +1,5 @@
 MAKELEVEL=1
-TMPDIR=TMPDIR
+TMPDIR=
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar

Index: src/usr.bin/make/unit-tests/objdir-writable.exp
diff -u src/usr.bin/make/unit-tests/objdir-writable.exp:1.3 src/usr.bin/make/unit-tests/objdir-writable.exp:1.4
--- src/usr.bin/make/unit-tests/objdir-writable.exp:1.3	Sun Jul  4 01:28:54 2021
+++ src/usr.bin/make/unit-tests/objdir-writable.exp	Wed Feb  9 18:54:19 2022
@@ -1,5 +1,5 @@
-make warning: TMPDIR/roobj: Permission denied.
-TMPDIR
-TMPDIR/roobj
-TMPDIR/roobj
+make warning: /roobj: Permission denied.
+
+/roobj
+/roobj
 exit status 0



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

2022-02-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  9 18:54:19 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile cmdline.exp export.exp
objdir-writable.exp

Log Message:
tests/make: use more distinctive placeholder for TMPDIR


To generate a diff of this commit:
cvs rdiff -u -r1.303 -r1.304 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmdline.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/export.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/objdir-writable.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

2022-02-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb  5 10:41:15 UTC 2022

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

Log Message:
tests/make: document and try to reproduce the crash in Parse_IsVar

Fixed in parse.c 1.662 from today.  To actually crash make, the end of
the expanded dependency line must be at the end of a mapped region.
There is no guaranteed crash, as this depends on the memory allocator.
NetBSD's jemalloc allocates large contiguous regions, making it less
likely for an allocation to end up at the end of a mapped region.  The
memory allocators used by FreeBSD and OpenBSD are better at detecting
such bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.3 src/usr.bin/make/unit-tests/var-scope-local.mk:1.4
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.3	Sat Jan 29 00:52:53 2022
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Sat Feb  5 10:41:15 2022
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.3 2022/01/29 00:52:53 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.4 2022/02/05 10:41:15 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
@@ -198,3 +198,32 @@ a_use: .USE VAR=use
 
 all: var-scope-local-use.o
 var-scope-local-use.o: a_use
+
+
+# Since parse.c 1.656 from 2022-01-27 and before parse.c 1.662 from
+# 2022-02-05, there was an out-of-bounds read in Parse_IsVar when looking for
+# a variable assignment in a dependency line with trailing whitespace.  Lines
+# without trailing whitespace were not affected.  Global variable assignments
+# were guaranteed to have no trailing whitespace and were thus not affected.
+#
+# Try to reproduce some variants that may lead to a crash, depending on the
+# memory allocator.  To get a crash, the terminating '\0' of the line must be
+# the last byte of a memory page.  The expression '${:U}' forces this trailing
+# whitespace.
+
+# On FreeBSD x86_64, a crash could in some cases be forced using the following
+# line, which has length 47, so the terminating '\0' may end up at an address
+# of the form 0x___Xfff:
+Try_to_crash_FreeBSD.xx: 12345 ${:U}
+
+# The following line has length 4095, so line[4095] == '\0'.  If the line is
+# allocated on a page boundary and the following page is not mapped, this line
+# leads to a segmentation fault.
+${:U:range=511:@_@1234567@:ts.}: 12345 ${:U}
+
+# The following line has length 8191, so line[8191] == '\0'.  If the line is
+# allocated on a page boundary and the following page is not mapped, this line
+# leads to a segmentation fault.
+${:U:range=1023:@_@1234567@:ts.}: 12345 ${:U}
+
+12345:



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

2022-02-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Feb  5 10:41:15 UTC 2022

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

Log Message:
tests/make: document and try to reproduce the crash in Parse_IsVar

Fixed in parse.c 1.662 from today.  To actually crash make, the end of
the expanded dependency line must be at the end of a mapped region.
There is no guaranteed crash, as this depends on the memory allocator.
NetBSD's jemalloc allocates large contiguous regions, making it less
likely for an allocation to end up at the end of a mapped region.  The
memory allocators used by FreeBSD and OpenBSD are better at detecting
such bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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

2022-01-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 10:21:26 UTC 2022

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

Log Message:
tests/make: sync comment in test for recursive variable


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-recursive.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-recursive.mk
diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.3 src/usr.bin/make/unit-tests/var-recursive.mk:1.4
--- src/usr.bin/make/unit-tests/var-recursive.mk:1.3	Sat Jan 29 10:09:37 2022
+++ src/usr.bin/make/unit-tests/var-recursive.mk	Sat Jan 29 10:21:26 2022
@@ -1,4 +1,4 @@
-# $NetBSD: var-recursive.mk,v 1.3 2022/01/29 10:09:37 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.4 2022/01/29 10:21:26 rillig Exp $
 #
 # Tests for variable expressions that refer to themselves and thus
 # cannot be evaluated.
@@ -46,8 +46,8 @@ V=	$V
 
 # If a recursive variable is accessed in a command of a target, the makefiles
 # are not parsed anymore, so there is no location information from the
-# .includes and .for directives.  TODO: In such a case, use the target
-# definition to provide at least a hint to the location.
+# .includes and .for directives.  In such a case, use the location of the last
+# command of the target to provide at least a hint to the location.
 VAR=	${VAR}
 target:
 	: OK



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

2022-01-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 10:21:26 UTC 2022

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

Log Message:
tests/make: sync comment in test for recursive variable


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-recursive.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

2022-01-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 10:09:37 UTC 2022

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

Log Message:
tests/make: demonstrate recursive variable in target


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-recursive.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-recursive.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

2022-01-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 10:09:37 UTC 2022

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

Log Message:
tests/make: demonstrate recursive variable in target


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-recursive.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-recursive.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-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.3 src/usr.bin/make/unit-tests/var-recursive.exp:1.4
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.3	Sat Jan 29 09:38:27 2022
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Sat Jan 29 10:09:37 2022
@@ -12,4 +12,8 @@ Variable V is recursive.
 	in var-recursive.mk:43
 
 make: stopped in unit-tests
+: OK
+Variable VAR is recursive.
+
+make: stopped in unit-tests
 exit status 0

Index: src/usr.bin/make/unit-tests/var-recursive.mk
diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.2 src/usr.bin/make/unit-tests/var-recursive.mk:1.3
--- src/usr.bin/make/unit-tests/var-recursive.mk:1.2	Sat Oct 31 13:45:00 2020
+++ src/usr.bin/make/unit-tests/var-recursive.mk	Sat Jan 29 10:09:37 2022
@@ -1,9 +1,9 @@
-# $NetBSD: var-recursive.mk,v 1.2 2020/10/31 13:45:00 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.3 2022/01/29 10:09:37 rillig Exp $
 #
 # Tests for variable expressions that refer to themselves and thus
 # cannot be evaluated.
 
-TESTS=	direct indirect conditional short
+TESTS=	direct indirect conditional short target
 
 # Since make exits immediately when it detects a recursive expression,
 # the actual tests are run in sub-makes.
@@ -42,6 +42,18 @@ CONDITIONAL=	${1:?ok:${CONDITIONAL}}
 V=	$V
 .  info $V
 
+.elif ${TEST} == target
+
+# If a recursive variable is accessed in a command of a target, the makefiles
+# are not parsed anymore, so there is no location information from the
+# .includes and .for directives.  TODO: In such a case, use the target
+# definition to provide at least a hint to the location.
+VAR=	${VAR}
+target:
+	: OK
+	: ${VAR}
+	: OK
+
 .else
 .  error Unknown test "${TEST}"
 .endif



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

2022-01-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 00:52:53 UTC 2022

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

Log Message:
tests/make: extend and isolate tests for target-local variables

Reusing the target var-scope-local.o for several tests made the test
more difficult to understand than necessary.  The test names '2' and '3'
didn't convey any meaning.

Instead, add more test targets that are named after what they test.  Add
tests for each of the 5 variable assignment operators, to demonstrate an
inconsistency between '+=' and '?='.

Add tests for the built-in target-local variables as well and explain
the general concepts, in particular the exact point where target-local
expressions are expanded.

The lines in the expected output file are not generated in the same
order as they appear in the makefile, so allow the 'expect' lines in
non-linear order, in check-expect.lua.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/check-expect.lua
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-scope-local.exp \
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/check-expect.lua
diff -u src/usr.bin/make/unit-tests/check-expect.lua:1.1 src/usr.bin/make/unit-tests/check-expect.lua:1.2
--- src/usr.bin/make/unit-tests/check-expect.lua:1.1	Sat Jan 15 12:35:18 2022
+++ src/usr.bin/make/unit-tests/check-expect.lua	Sat Jan 29 00:52:53 2022
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.1 2022/01/15 12:35:18 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.2 2022/01/29 00:52:53 rillig Exp $
 
 --[[
 
@@ -82,6 +82,9 @@ local function check_mk(mk_fname)
   mk_fname, mk_lineno, exp_fname, prev_expect_line + 1, text)
   end
 end
+if mk_line:match("^#%s*expect%-reset$") then
+  prev_expect_line = 0
+end
 
 ---@param text string
 for offset, text in mk_line:gmatch("#%s*expect([+%-]%d+):%s*(.*)") do

Index: src/usr.bin/make/unit-tests/var-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.2 src/usr.bin/make/unit-tests/var-scope-local.exp:1.3
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.2	Thu Jan 27 06:56:27 2022
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Sat Jan 29 00:52:53 2022
@@ -1,10 +1,21 @@
+Global: .ALLTARGETS =  one
+Global: .ALLTARGETS =  one two
+Var_Parse: ${.MAKE.TARGET_LOCAL_VARIABLES} (eval)
+Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
+Var_SetExpand: variable name "" expands to empty string, with value "three" - ignored
+Global: one two = 
+Global: one two = three
+Global: .MAKEFLAGS =  -r -k -d v -d
+Global: .MAKEFLAGS =  -r -k -d v -d 0
 : 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 "." VAR="local".
-: Making var-scope-local2.c out of nothing.
-: Making var-scope-local2.o from var-scope-local2.c.
-: Making basename "var-scope-local2.o" in "." from "var-scope-local2.c" in "." VAR="local to var-scope-local2.o".
-: Making var-scope-local3.c out of nothing.
-: var-scope-local3.o uses .USE VAR="global+local"
-: all overwritten VAR="global"
+: Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
+: Making var-scope-local-assign.o with VAR="local".
+: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+: Making var-scope-local-append-global.o with VAR="global+local".
+: Making var-scope-local-default.o with VAR="global".
+: Making var-scope-local-subst.o with VAR="global+local".
+: Making var-scope-local-shell.o with VAR="output".
+: var-scope-local-use.o uses .USE 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.2 src/usr.bin/make/unit-tests/var-scope-local.mk:1.3
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.2	Thu Jan 27 06:56:27 2022
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Sat Jan 29 00:52:53 2022
@@ -1,16 +1,67 @@
-# $NetBSD: var-scope-local.mk,v 1.2 2022/01/27 06:56:27 sjg Exp $
+# $NetBSD: var-scope-local.mk,v 1.3 2022/01/29 00:52:53 rillig Exp $
 #
-# Tests for target-local variables, such as ${.TARGET} or $@.
-
-# TODO: Implementation
-
-# Ensure that the name of the variable is exactly the given one.
-# The variable "@" is an alias for ".TARGET", so the implementation might
+# Tests for target-local variables, such as ${.TARGET} or $@.  These variables
+# are relatively short-lived as they are created just before making the
+# target.  In contrast, global variables are typically created when the
+# makefiles are read in.
+#
+# The 7 built-in target-local variables are 

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

2022-01-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 29 00:52:53 UTC 2022

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

Log Message:
tests/make: extend and isolate tests for target-local variables

Reusing the target var-scope-local.o for several tests made the test
more difficult to understand than necessary.  The test names '2' and '3'
didn't convey any meaning.

Instead, add more test targets that are named after what they test.  Add
tests for each of the 5 variable assignment operators, to demonstrate an
inconsistency between '+=' and '?='.

Add tests for the built-in target-local variables as well and explain
the general concepts, in particular the exact point where target-local
expressions are expanded.

The lines in the expected output file are not generated in the same
order as they appear in the makefile, so allow the 'expect' lines in
non-linear order, in check-expect.lua.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/check-expect.lua
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-scope-local.exp \
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

2022-01-27 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 21:50:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp

Log Message:
numEntries can vary


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-hash.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

2022-01-27 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 21:50:50 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp

Log Message:
numEntries can vary


To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-hash.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.301 src/usr.bin/make/unit-tests/Makefile:1.302
--- src/usr.bin/make/unit-tests/Makefile:1.301	Thu Jan 27 02:24:46 2022
+++ src/usr.bin/make/unit-tests/Makefile	Thu Jan 27 21:50:50 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.301 2022/01/27 02:24:46 sjg Exp $
+# $NetBSD: Makefile,v 1.302 2022/01/27 21:50:50 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -503,6 +503,7 @@ SED_CMDS.opt-chdir=		-e 's,\(nonexistent
 SED_CMDS.opt-debug-graph1=	${STD_SED_CMDS.dg1}
 SED_CMDS.opt-debug-graph2=	${STD_SED_CMDS.dg2}
 SED_CMDS.opt-debug-graph3=	${STD_SED_CMDS.dg3}
+SED_CMDS.opt-debug-hash=	-e 's,\(numEntries\)=[1-9][0-9],\1=,'
 SED_CMDS.opt-debug-jobs=	-e 's,([0-9][0-9]*),(),'
 SED_CMDS.opt-debug-jobs+=	-e 's,pid [0-9][0-9]*,pid ,'
 SED_CMDS.opt-debug-jobs+=	-e 's,Process [0-9][0-9]*,Process ,'

Index: src/usr.bin/make/unit-tests/opt-debug-hash.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.3 src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.4
--- src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.3	Sat Jan 22 18:59:24 2022
+++ src/usr.bin/make/unit-tests/opt-debug-hash.exp	Thu Jan 27 21:50:50 2022
@@ -1,6 +1,6 @@
 make: "opt-debug-hash.mk" line 11: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 HashTable targets: size=16 numEntries=0 maxchain=0
-HashTable Global variables: size=16 numEntries=23 maxchain=3
+HashTable Global variables: size=16 numEntries= maxchain=3
 make: stopped in unit-tests
 exit status 1



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 20:15:14 UTC 2022

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

Log Message:
tests/make: add more edge cases for expansion of .for loop body


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.14 -r1.15 \
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.15 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.16
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jan 27 20:15:14 2022
@@ -125,6 +125,15 @@ For: loop body:
 # ${:U${:U\$\$}}
 For: end for 1
 For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U${.TARGET}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: loop body:
+# ${:U$${.TARGET\}}
+For: end for 1
+For: loop body:
 # ${:U(((}
 For: loop body:
 # ${:U{{{}

Index: src/usr.bin/make/unit-tests/directive-for-escape.mk
diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.15
--- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.14	Thu Jan 27 11:26:44 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.mk	Thu Jan 27 20:15:14 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-for-escape.mk,v 1.14 2022/01/27 11:26:44 rillig Exp $
+# $NetBSD: directive-for-escape.mk,v 1.15 2022/01/27 20:15:14 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
@@ -65,7 +65,7 @@ ${:U\\}=	backslash
 # FIXME: There was no expression '$\' in the original text of the previous
 # line, that's a surprise in the parser.
 # The modifier ':U' unescapes the '\$' to a simple '$'.
-# expect+4: ${UNDEF:U\$
+# expect+4: ${UNDEF:U\backslash$
 VALUES=		$${UNDEF:U\$$\$$ {{}} end}
 # XXX: Where in the code does the '\$\$' get converted into a single '\$'?
 .for i in ${VALUES}
@@ -178,6 +178,20 @@ ${closing-brace}=		# alte
 # $i
 .endfor
 
+# The expression '${.TARGET}' must be preserved as it is one of the 7 built-in
+# target-local variables.  See for.c 1.45 from 2009-01-14.
+.for i in ${.TARGET} $${.TARGET} $$${.TARGET} {.TARGET}
+# $i
+.endfor
+# expect: # ${:U${.TARGET}}
+# XXX: Why does '$' result in the same text as '$$'?
+# expect: # ${:U${.TARGET}}
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+# XXX: Why does '$' result in the same text as '$$'?
+# XXX: Why does the '$$' before the '${.TARGET}' lead to an escaped '}'?
+# expect: # ${:U$${.TARGET\}}
+
 .for i in ((( {{{ ))) }}}
 # $i
 .endfor



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 20:15:14 UTC 2022

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

Log Message:
tests/make: add more edge cases for expansion of .for loop body


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.14 -r1.15 \
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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:26:44 UTC 2022

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

Log Message:
tests/make: explain escaping in .for loops, add more test cases


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.13 -r1.14 \
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.14 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.15
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.14	Sun Jan  9 20:53:53 2022
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Jan 27 11:26:44 2022
@@ -27,29 +27,29 @@ make: "directive-for-escape.mk" line 43:
 For: end for 1
 For: loop body:
 .  info ${:U\${UNDEF\:U\\$\\$}
-make: "directive-for-escape.mk" line 57: ${UNDEF:U\$
+make: "directive-for-escape.mk" line 72: ${UNDEF:U\backslash$
 For: loop body:
 .  info ${:U{{\}\}}
-make: "directive-for-escape.mk" line 57: {{}}
+make: "directive-for-escape.mk" line 72: {{}}
 For: loop body:
 .  info ${:Uend\}}
-make: "directive-for-escape.mk" line 57: end}
+make: "directive-for-escape.mk" line 72: end}
 For: end for 1
 For: loop body:
 .  info ${:Ubegin<${UNDEF:Ufallback:N{{{>end}
-make: "directive-for-escape.mk" line 69: beginend
+make: "directive-for-escape.mk" line 84: beginend
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 77: $
+make: "directive-for-escape.mk" line 92: $
 For: end for 1
 For: loop body:
 .  info ${NUMBERS} ${:Ureplaced}
-make: "directive-for-escape.mk" line 85: one two three replaced
+make: "directive-for-escape.mk" line 100: one two three replaced
 For: end for 1
 For: loop body:
 .  info ${:Ureplaced}
-make: "directive-for-escape.mk" line 95: replaced
+make: "directive-for-escape.mk" line 110: replaced
 For: end for 1
 For: loop body:
 .  info .$$i: ${:Uinner}
@@ -62,47 +62,76 @@ For: loop body:
 .  info . $${i2}: ${i2}
 .  info . $${i,}: ${i,}
 .  info .  adjacent: ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner}
-make: "directive-for-escape.mk" line 103: .$i: inner
-make: "directive-for-escape.mk" line 104: .  ${i}: inner
-make: "directive-for-escape.mk" line 105: .   ${i:M*}: inner
-make: "directive-for-escape.mk" line 106: .  $(i): inner
-make: "directive-for-escape.mk" line 107: .   $(i:M*): inner
-make: "directive-for-escape.mk" line 108: . ${i${:U}}: outer
-make: "directive-for-escape.mk" line 109: .${i\}}: inner}
-make: "directive-for-escape.mk" line 110: . ${i2}: two
-make: "directive-for-escape.mk" line 111: . ${i,}: comma
-make: "directive-for-escape.mk" line 112: .  adjacent: innerinnerinnerinner
+make: "directive-for-escape.mk" line 118: .$i: inner
+make: "directive-for-escape.mk" line 119: .  ${i}: inner
+make: "directive-for-escape.mk" line 120: .   ${i:M*}: inner
+make: "directive-for-escape.mk" line 121: .  $(i): inner
+make: "directive-for-escape.mk" line 122: .   $(i:M*): inner
+make: "directive-for-escape.mk" line 123: . ${i${:U}}: outer
+make: "directive-for-escape.mk" line 124: .${i\}}: inner}
+make: "directive-for-escape.mk" line 125: . ${i2}: two
+make: "directive-for-escape.mk" line 126: . ${i,}: comma
+make: "directive-for-escape.mk" line 127: .  adjacent: innerinnerinnerinner
 For: end for 1
 For: loop body:
 .  info eight  and no cents.
 .  info eight ${:Udollar}${:Udollar}${:Udollar}${:Udollar} and no cents.
-make: "directive-for-escape.mk" line 120: eight  and no cents.
-make: "directive-for-escape.mk" line 121: eight dollardollardollardollar and no cents.
-make: "directive-for-escape.mk" line 130: eight  and no cents.
+make: "directive-for-escape.mk" line 135: eight  and no cents.
+make: "directive-for-escape.mk" line 136: eight dollardollardollardollar and no cents.
+make: "directive-for-escape.mk" line 145: eight  and no cents.
 For: end for 1
-make: "directive-for-escape.mk" line 137: newline in .for value
-make: "directive-for-escape.mk" line 137: newline in .for value
+make: "directive-for-escape.mk" line 152: newline in .for value
+make: "directive-for-escape.mk" line 152: newline in .for value
 For: loop body:
 .  info short: ${:U" "}
 .  info long: ${:U" "}
-make: "directive-for-escape.mk" line 138: short: " "
-make: "directive-for-escape.mk" line 139: long: " "
+make: "directive-for-escape.mk" line 153: short: " "
+make: "directive-for-escape.mk" line 154: long: " "
 For: end for 1
 For: loop body:
 For: end for 1
-Parse_PushInput: .for loop in directive-for-escape.mk, line 152
-make: "directive-for-escape.mk" line 152: newline in .for value
-	in .for loop from 

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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 11:26:44 UTC 2022

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

Log Message:
tests/make: explain escaping in .for loops, add more test cases


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.13 -r1.14 \
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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:42:02 UTC 2022

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

Log Message:
tests/make: test hash code collisions of variable names

In HashEntry_KeyEquals, the line 'return false' was not covered by any
tests before.  Since it is an edge case that two variable names (or
other keys) have the same 32-bit hash code and still differ, better test
for that edge case explicitly since a bug in this place would be rare
and hard to find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varname.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/varname.mk
diff -u src/usr.bin/make/unit-tests/varname.mk:1.8 src/usr.bin/make/unit-tests/varname.mk:1.9
--- src/usr.bin/make/unit-tests/varname.mk:1.8	Mon Nov  2 22:59:48 2020
+++ src/usr.bin/make/unit-tests/varname.mk	Thu Jan 27 10:42:02 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varname.mk,v 1.8 2020/11/02 22:59:48 rillig Exp $
+# $NetBSD: varname.mk,v 1.9 2022/01/27 10:42:02 rillig Exp $
 #
 # Tests for special variables, such as .MAKE or .PARSEDIR.
 # And for variable names in general.
@@ -41,4 +41,46 @@ ${VARNAME}=	try3
 
 .MAKEFLAGS: -d0
 
+# All variable names of a scope are stored in the same hash table, using a
+# simple hash function.  Ensure that HashEntry_KeyEquals handles collisions
+# correctly and that the correct variable is looked up.  The strings "0x" and
+# "1Y" have the same hash code, as 31 * '0' + 'x' == 31 * '1' + 'Y'.
+V.0x=	0x
+V.1Y=	1Y
+.if ${V.0x} != "0x" || ${V.1Y} != "1Y"
+.  error
+.endif
+
+# The string "ASDZguv", when used as a prefix of a variable name, keeps the
+# hash code unchanged, its own hash code is 0.
+ASDZguvV.0x=	0x
+ASDZguvV.1Y=	1Y
+.if ${ASDZguvV.0x} != "0x"
+.  error
+.elif ${ASDZguvV.1Y} != "1Y"
+.  error
+.endif
+
+# Ensure that variables with the same hash code whose name is a prefix of the
+# other can be accessed.  In this case, the shorter variable name is defined
+# first to make it appear later in the bucket of the hash table.
+ASDZguv=	once
+ASDZguvASDZguv=	twice
+.if ${ASDZguv} != "once"
+.  error
+.elif ${ASDZguvASDZguv} != "twice"
+.  error
+.endif
+
+# Ensure that variables with the same hash code whose name is a prefix of the
+# other can be accessed.  In this case, the longer variable name is defined
+# first to make it appear later in the bucket of the hash table.
+ASDZguvASDZguv.param=	twice
+ASDZguv.param=		once
+.if ${ASDZguv.param} != "once"
+.  error
+.elif ${ASDZguvASDZguv.param} != "twice"
+.  error
+.endif
+
 all:



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

2022-01-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 27 10:42:02 UTC 2022

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

Log Message:
tests/make: test hash code collisions of variable names

In HashEntry_KeyEquals, the line 'return false' was not covered by any
tests before.  Since it is an edge case that two variable names (or
other keys) have the same 32-bit hash code and still differ, better test
for that edge case explicitly since a bug in this place would be rare
and hard to find.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varname.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

2022-01-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 06:56:27 UTC 2022

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

Log Message:
Unit test for local variables


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local.exp \
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.1 src/usr.bin/make/unit-tests/var-scope-local.exp:1.2
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.1	Sun Jan 23 16:25:54 2022
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Thu Jan 27 06:56:27 2022
@@ -1,5 +1,10 @@
 : 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 ".".
-: all overwritten
+: Making basename "var-scope-local.o" in "." from "var-scope-local.c" in "." VAR="local".
+: Making var-scope-local2.c out of nothing.
+: Making var-scope-local2.o from var-scope-local2.c.
+: Making basename "var-scope-local2.o" in "." from "var-scope-local2.c" in "." VAR="local to var-scope-local2.o".
+: Making var-scope-local3.c out of nothing.
+: var-scope-local3.o uses .USE VAR="global+local"
+: all overwritten VAR="global"
 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.1 src/usr.bin/make/unit-tests/var-scope-local.mk:1.2
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.1	Sun Jan 23 16:25:54 2022
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Thu Jan 27 06:56:27 2022
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.1 2022/01/23 16:25:54 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.2 2022/01/27 06:56:27 sjg Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.
 
@@ -28,7 +28,7 @@ all:
 
 .SUFFIXES: .c .o
 
-var-scope-local.c:
+var-scope-local.c var-scope-local2.c var-scope-local3.c:
 	: Making ${.TARGET} out of nothing.
 
 .c.o:
@@ -36,10 +36,33 @@ var-scope-local.c:
 
 	# The local variables @F, @D, 

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

2022-01-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 06:56:27 UTC 2022

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

Log Message:
Unit test for local variables


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-scope-local.exp \
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

2022-01-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 02:24:46 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-where-am-i.mk

Log Message:
Do not allow /usr/obj to cause failure.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-where-am-i.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

2022-01-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 27 02:24:46 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-where-am-i.mk

Log Message:
Do not allow /usr/obj to cause failure.


To generate a diff of this commit:
cvs rdiff -u -r1.300 -r1.301 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-where-am-i.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.300 src/usr.bin/make/unit-tests/Makefile:1.301
--- src/usr.bin/make/unit-tests/Makefile:1.300	Sun Jan 23 18:00:53 2022
+++ src/usr.bin/make/unit-tests/Makefile	Thu Jan 27 02:24:46 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.300 2022/01/23 18:00:53 rillig Exp $
+# $NetBSD: Makefile,v 1.301 2022/01/27 02:24:46 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -513,6 +513,7 @@ SED_CMDS.opt-debug-jobs+=	-e 's,^\(.Comm
 SED_CMDS.opt-debug-lint+=	${STD_SED_CMDS.regex}
 SED_CMDS.opt-jobs-no-action=	${STD_SED_CMDS.hide-from-output}
 SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
+SED_CMDS.opt-where-am-i=	-e '/usr.obj/d'
 # For Compat_RunCommand, useShell == false.
 SED_CMDS.sh-dots=		-e 's,^.*\.\.\.:.*,,'
 # For Compat_RunCommand, useShell == true.

Index: src/usr.bin/make/unit-tests/opt-where-am-i.mk
diff -u src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.3 src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.4
--- src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.3	Sat Jan 22 17:10:51 2022
+++ src/usr.bin/make/unit-tests/opt-where-am-i.mk	Thu Jan 27 02:24:46 2022
@@ -1,4 +1,4 @@
-# $NetBSD: opt-where-am-i.mk,v 1.3 2022/01/22 17:10:51 rillig Exp $
+# $NetBSD: opt-where-am-i.mk,v 1.4 2022/01/27 02:24:46 sjg Exp $
 #
 # Tests for the -w command line option, which outputs the current directory
 # at the beginning and end of running make.  This is useful when building
@@ -10,5 +10,5 @@
 
 all:
 .if ${.CURDIR} != "/"
-	@${MAKE} -r -f ${MAKEFILE:tA} -C /
+	@MAKE_OBJDIR_CHECK_WRITABLE=no ${MAKE} -r -f ${MAKEFILE:tA} -C /
 .endif



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

2022-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jan 26 22:47:03 UTC 2022

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

Log Message:
tests/make: test meta mode in jobs mode


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-meta.exp \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-meta.mk
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.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/depsrc-meta.exp
diff -u src/usr.bin/make/unit-tests/depsrc-meta.exp:1.2 src/usr.bin/make/unit-tests/depsrc-meta.exp:1.3
--- src/usr.bin/make/unit-tests/depsrc-meta.exp:1.2	Fri Nov 27 08:36:10 2020
+++ src/usr.bin/make/unit-tests/depsrc-meta.exp	Wed Jan 26 22:47:03 2022
@@ -2,4 +2,6 @@ Skipping meta for actual-test: no comman
 Skipping meta for .END: .SPECIAL
 Targets from meta mode:
 | TARGET depsrc-meta-target
+Targets from meta mode in jobs mode:
+| TARGET depsrc-meta-target
 exit status 0
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.2 src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk	Wed Jan 26 22:47:03 2022
@@ -1,8 +1,24 @@
-# $NetBSD: varname-dot-make-jobs.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-make-jobs.mk,v 1.3 2022/01/26 22:47:03 rillig Exp $
 #
-# Tests for the special .MAKE.JOBS variable.
+# 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.
 
-# TODO: Implementation
+.MAIN: all
+
+echo: .PHONY
+	@echo ${.MAKE.JOBS:Uundefined}
 
 all:
-	@:;
+	@${MAKE} -r -f ${MAKEFILE} echo
+	@${MAKE} -r -f ${MAKEFILE} echo -j1
+	@${MAKE} -r -f ${MAKEFILE} echo -j5
+	@${MAKE} -r -f ${MAKEFILE} echo -j20
+	@${MAKE} -r -f ${MAKEFILE} echo -j0001
+
+# expect: undefined
+# expect: 1
+# expect: 5
+# expect: 20
+# The value of .MAKE.JOBS is the exact text given in the command line, not the
+# canonical number.  This doesn't have practical consequences though.
+# expect: 0001

Index: src/usr.bin/make/unit-tests/depsrc-meta.mk
diff -u src/usr.bin/make/unit-tests/depsrc-meta.mk:1.5 src/usr.bin/make/unit-tests/depsrc-meta.mk:1.6
--- src/usr.bin/make/unit-tests/depsrc-meta.mk:1.5	Wed Jan 26 22:19:25 2022
+++ src/usr.bin/make/unit-tests/depsrc-meta.mk	Wed Jan 26 22:47:03 2022
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc-meta.mk,v 1.5 2022/01/26 22:19:25 rillig Exp $
+# $NetBSD: depsrc-meta.mk,v 1.6 2022/01/26 22:47:03 rillig Exp $
 #
 # Tests for the special source .META in dependency declarations.
 
@@ -18,10 +18,13 @@ depsrc-meta-target: .META
 	@rm -f ${.TARGET}-file
 
 check-results:
-	@echo 'Targets from meta mode:'
+	@echo 'Targets from meta mode${.MAKE.JOBS:D in jobs mode}:'
 	@awk '/^TARGET/ { print "| " $$0 }' depsrc-meta-target.meta
 	@rm depsrc-meta-target.meta
 
 all:
-	@${MAKE} -f ${MAKEFILE} actual-test
-	@${MAKE} -f ${MAKEFILE} check-results
+	@${MAKE} -r -f ${MAKEFILE} actual-test
+	@${MAKE} -r -f ${MAKEFILE} check-results
+
+	@${MAKE} -r -f ${MAKEFILE} actual-test -j1
+	@${MAKE} -r -f ${MAKEFILE} check-results -j1

Index: src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.1	Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp	Wed Jan 26 22:47:03 2022
@@ -1 +1,8 @@
+undefined
+1
+--- echo ---
+5
+--- echo ---
+20
+0001
 exit status 0



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

2022-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jan 26 22:47:03 UTC 2022

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

Log Message:
tests/make: test meta mode in jobs mode


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-meta.exp \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/depsrc-meta.mk
cvs rdiff -u -r1.1 -r1.2 \
src/usr.bin/make/unit-tests/varname-dot-make-jobs.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

2022-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jan 26 22:19:25 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.mk

Log Message:
tests/make: remove unnecessary conditional processing for meta test

The .if/.else distracted from the main topic of the test and made it too
hard to see the main targets.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc-meta.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/depsrc-meta.mk
diff -u src/usr.bin/make/unit-tests/depsrc-meta.mk:1.4 src/usr.bin/make/unit-tests/depsrc-meta.mk:1.5
--- src/usr.bin/make/unit-tests/depsrc-meta.mk:1.4	Fri Nov 27 08:39:07 2020
+++ src/usr.bin/make/unit-tests/depsrc-meta.mk	Wed Jan 26 22:19:25 2022
@@ -1,31 +1,27 @@
-# $NetBSD: depsrc-meta.mk,v 1.4 2020/11/27 08:39:07 rillig Exp $
+# $NetBSD: depsrc-meta.mk,v 1.5 2022/01/26 22:19:25 rillig Exp $
 #
 # Tests for the special source .META in dependency declarations.
 
 # TODO: Implementation
 # TODO: Explanation
 
-.if make(actual-test)
+.MAIN: all
 
+.if make(actual-test)
 .MAKEFLAGS: -dM
 .MAKE.MODE=	meta curDirOk=true
+.endif
 
 actual-test: depsrc-meta-target
 depsrc-meta-target: .META
 	@> ${.TARGET}-file
 	@rm -f ${.TARGET}-file
 
-.elif make(check-results)
-
 check-results:
 	@echo 'Targets from meta mode:'
 	@awk '/^TARGET/ { print "| " $$0 }' depsrc-meta-target.meta
 	@rm depsrc-meta-target.meta
 
-.else
-
 all:
 	@${MAKE} -f ${MAKEFILE} actual-test
 	@${MAKE} -f ${MAKEFILE} check-results
-
-.endif



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

2022-01-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jan 26 22:19:25 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: depsrc-meta.mk

Log Message:
tests/make: remove unnecessary conditional processing for meta test

The .if/.else distracted from the main topic of the test and made it too
hard to see the main targets.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc-meta.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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 21:48:59 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-main.exp deptgt-main.mk
directive-dinclude.exp directive-dinclude.mk
directive-hyphen-include.exp directive-hyphen-include.mk
directive-if.exp directive-if.mk directive-ifdef.exp
directive-ifdef.mk directive-sinclude.mk varmod-to-separator.mk
varname-dot-make-pid.mk varname-dot-make-ppid.mk

Log Message:
tests/make: add a few more tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-main.exp \
src/usr.bin/make/unit-tests/directive-dinclude.exp \
src/usr.bin/make/unit-tests/directive-dinclude.mk \
src/usr.bin/make/unit-tests/directive-hyphen-include.exp \
src/usr.bin/make/unit-tests/directive-hyphen-include.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-main.mk \
src/usr.bin/make/unit-tests/directive-ifdef.exp \
src/usr.bin/make/unit-tests/directive-sinclude.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-if.exp \
src/usr.bin/make/unit-tests/varmod-to-separator.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-if.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-ifdef.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-make-pid.mk \
src/usr.bin/make/unit-tests/varname-dot-make-ppid.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/deptgt-main.exp
diff -u src/usr.bin/make/unit-tests/deptgt-main.exp:1.1 src/usr.bin/make/unit-tests/deptgt-main.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-main.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/deptgt-main.exp	Sun Jan 23 21:48:59 2022
@@ -1 +1,2 @@
+This target real-main is the one that is made.
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-dinclude.exp
diff -u src/usr.bin/make/unit-tests/directive-dinclude.exp:1.1 src/usr.bin/make/unit-tests/directive-dinclude.exp:1.2
--- src/usr.bin/make/unit-tests/directive-dinclude.exp:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-dinclude.exp	Sun Jan 23 21:48:59 2022
@@ -1 +1,4 @@
-exit status 0
+make: "directive-dinclude-error.inc" line 1: 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-dinclude.mk
diff -u src/usr.bin/make/unit-tests/directive-dinclude.mk:1.1 src/usr.bin/make/unit-tests/directive-dinclude.mk:1.2
--- src/usr.bin/make/unit-tests/directive-dinclude.mk:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-dinclude.mk	Sun Jan 23 21:48:59 2022
@@ -1,9 +1,24 @@
-# $NetBSD: directive-dinclude.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+# $NetBSD: directive-dinclude.mk,v 1.2 2022/01/23 21:48:59 rillig Exp $
 #
 # Tests for the .dinclude directive, which includes another file,
-# typically named .depend.
+# silently skipping it if it cannot be opened.  This is primarily used for
+# including '.depend' files, that's where the 'd' comes from.
+#
+# The 'silently skipping' only applies to the case where the file cannot be
+# opened.  Parse errors and other errors are handled the same way as in the
+# other .include directives.
+
+# No complaint that there is no such file.
+.dinclude "${.CURDIR}/directive-dinclude-nonexistent.inc"
+
+# No complaint either, even though the operating system error is ENOTDIR, not
+# ENOENT.
+.dinclude "${MAKEFILE}/subdir"
 
-# TODO: Implementation
+# Errors that are not related to opening the file are still reported.
+# expect: make: "directive-dinclude-error.inc" line 1: Invalid line type
+_!=	echo 'syntax error' > directive-dinclude-error.inc
+.dinclude "${.CURDIR}/directive-dinclude-error.inc"
+_!=	rm directive-dinclude-error.inc
 
-all:
-	@:;
+all: .PHONY
Index: src/usr.bin/make/unit-tests/directive-hyphen-include.exp
diff -u src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.1 src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.2
--- src/usr.bin/make/unit-tests/directive-hyphen-include.exp:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.exp	Sun Jan 23 21:48:59 2022
@@ -1 +1,4 @@
-exit status 0
+make: "directive-hyphen-include-error.inc" line 1: 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-hyphen-include.mk
diff -u src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.1 src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.2
--- src/usr.bin/make/unit-tests/directive-hyphen-include.mk:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-hyphen-include.mk	Sun Jan 23 21:48:59 2022
@@ -1,9 +1,23 @@
-# $NetBSD: 

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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 21:48:59 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: deptgt-main.exp deptgt-main.mk
directive-dinclude.exp directive-dinclude.mk
directive-hyphen-include.exp directive-hyphen-include.mk
directive-if.exp directive-if.mk directive-ifdef.exp
directive-ifdef.mk directive-sinclude.mk varmod-to-separator.mk
varname-dot-make-pid.mk varname-dot-make-ppid.mk

Log Message:
tests/make: add a few more tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-main.exp \
src/usr.bin/make/unit-tests/directive-dinclude.exp \
src/usr.bin/make/unit-tests/directive-dinclude.mk \
src/usr.bin/make/unit-tests/directive-hyphen-include.exp \
src/usr.bin/make/unit-tests/directive-hyphen-include.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-main.mk \
src/usr.bin/make/unit-tests/directive-ifdef.exp \
src/usr.bin/make/unit-tests/directive-sinclude.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-if.exp \
src/usr.bin/make/unit-tests/varmod-to-separator.mk
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-if.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-ifdef.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-make-pid.mk \
src/usr.bin/make/unit-tests/varname-dot-make-ppid.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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 18:59:18 UTC 2022

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

Log Message:
tests/make: add more tests for the modifier ':ts'


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-to-separator.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-to-separator.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-to-separator.exp
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.9 src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.10
--- src/usr.bin/make/unit-tests/varmod-to-separator.exp:1.9	Sun Jan 23 18:00:53 2022
+++ src/usr.bin/make/unit-tests/varmod-to-separator.exp	Sun Jan 23 18:59:18 2022
@@ -16,6 +16,10 @@ make: Bad modifier ":ts\X" for variable 
 make: "varmod-to-separator.mk" line 213: Malformed conditional (${WORDS:ts\X})
 make: Bad modifier ":t\X" for variable "WORDS"
 make: "varmod-to-separator.mk" line 221: Malformed conditional (${WORDS:t\X} != "anything")
+make: Bad modifier ":ts\69" for variable ""
+make: "varmod-to-separator.mk" line 237: Malformed conditional (${:Ua b:ts\69})
+make: "varmod-to-separator.mk" line 246: Invalid character number at "1F60E}"
+make: "varmod-to-separator.mk" line 246: Malformed conditional (${:Ua b:ts\x1F60E})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-to-separator.mk
diff -u src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.8 src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-to-separator.mk:1.8	Sun Jan 23 18:00:53 2022
+++ src/usr.bin/make/unit-tests/varmod-to-separator.mk	Sun Jan 23 18:59:18 2022
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-to-separator.mk,v 1.8 2022/01/23 18:00:53 rillig Exp $
+# $NetBSD: varmod-to-separator.mk,v 1.9 2022/01/23 18:59:18 rillig Exp $
 #
 # Tests for the :ts variable modifier, which joins the words of the variable
 # using an arbitrary character as word separator.
@@ -222,8 +222,29 @@ WORDS=	one two three four five six
 .  info This line is not reached.
 .endif
 
-# TODO: This modifier used to accept decimal numbers as well, in the form
-# ':ts\120'.  When has this been changed to octal, and what happens now
-# for ':ts\90' ('Z' in decimal ASCII, undefined in octal)?
 
-# TODO: :ts\x1F600
+# Since 2003.07.23.18.06.46 and before 2016.03.07.20.20.35, the modifier ':ts'
+# interpreted an "octal escape" as decimal if the first digit was not '0'.
+.if ${:Ua b:ts\61} != "a1b"	# decimal would have been "a=b"
+.  error
+.endif
+
+# Since the character escape is always interpreted as octal, let's see what
+# happens for non-octal digits.  From 2003.07.23.18.06.46 to
+# 2016.02.27.16.20.06, the result was '1E2', since 2016.03.07.20.20.35 make no
+# longer accepts this escape and complains.
+# expect: make: Bad modifier ":ts\69" for variable ""
+.if ${:Ua b:ts\69}
+.  error
+.else
+.  error
+.endif
+
+# Try whether bmake is Unicode-ready.
+# expect+2: Invalid character number at "1F60E}"
+# expect+1: Malformed conditional (${:Ua b:ts\x1F60E})
+.if ${:Ua b:ts\x1F60E}		# U+1F60E "smiling face with sunglasses"
+.  error
+.else
+.  error
+.endif



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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 18:59:18 UTC 2022

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

Log Message:
tests/make: add more tests for the modifier ':ts'


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-to-separator.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-to-separator.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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 18:15:29 UTC 2022

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

Log Message:
tests/make: run nested makes with -r to reduce side effects


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/posix.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

2022-01-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 23 18:15:29 UTC 2022

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

Log Message:
tests/make: run nested makes with -r to reduce side effects


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/posix.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/posix.mk
diff -u src/usr.bin/make/unit-tests/posix.mk:1.2 src/usr.bin/make/unit-tests/posix.mk:1.3
--- src/usr.bin/make/unit-tests/posix.mk:1.2	Sat Oct 24 08:34:59 2020
+++ src/usr.bin/make/unit-tests/posix.mk	Sun Jan 23 18:15:29 2022
@@ -1,4 +1,4 @@
-# $NetBSD: posix.mk,v 1.2 2020/10/24 08:34:59 rillig Exp $
+# $NetBSD: posix.mk,v 1.3 2022/01/23 18:15:29 rillig Exp $
 
 all:	x plus subs err
 
@@ -14,11 +14,10 @@ plus:
 
 subs:
 	@echo make -n
-	@${.MAKE} -f ${MAKEFILE} -n plus
+	@${.MAKE} -r -f ${MAKEFILE} -n plus
 	@echo make -n -j1
-	@${.MAKE} -f ${MAKEFILE} -n -j1 plus
+	@${.MAKE} -r -f ${MAKEFILE} -n -j1 plus
 
 err:
 	@(echo Now we expect an error...; exit 1)
 	@echo "Oops! you shouldn't see this!"
-



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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 21:50:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: cond-op-parentheses.exp
cond-op-parentheses.mk deptgt-error.exp deptgt-error.mk
deptgt-ignore.exp deptgt-ignore.mk deptgt-interrupt.exp
deptgt-interrupt.mk directive-elifndef.mk

Log Message:
tests/make: add a few more tests, mainly for special targets


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-op-parentheses.exp \
src/usr.bin/make/unit-tests/deptgt-error.mk \
src/usr.bin/make/unit-tests/deptgt-ignore.mk \
src/usr.bin/make/unit-tests/deptgt-interrupt.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op-parentheses.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-error.exp \
src/usr.bin/make/unit-tests/deptgt-ignore.exp \
src/usr.bin/make/unit-tests/deptgt-interrupt.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-elifndef.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-parentheses.exp
diff -u src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.3 src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.4
--- src/usr.bin/make/unit-tests/cond-op-parentheses.exp:1.3	Tue Jan 19 17:49:13 2021
+++ src/usr.bin/make/unit-tests/cond-op-parentheses.exp	Sat Jan 22 21:50:41 2022
@@ -1,6 +1,7 @@
-make: "cond-op-parentheses.mk" line 13: Parentheses can be nested at least to depth 112.
-make: "cond-op-parentheses.mk" line 19: Malformed conditional (()
-make: "cond-op-parentheses.mk" line 29: Malformed conditional ())
+make: "cond-op-parentheses.mk" line 19: String comparison operator must be either == or !=
+make: "cond-op-parentheses.mk" line 22: Malformed conditional ((3) > 2)
+make: "cond-op-parentheses.mk" line 40: Malformed conditional (()
+make: "cond-op-parentheses.mk" line 53: Malformed conditional ())
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/deptgt-error.mk
diff -u src/usr.bin/make/unit-tests/deptgt-error.mk:1.3 src/usr.bin/make/unit-tests/deptgt-error.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt-error.mk:1.3	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/deptgt-error.mk	Sat Jan 22 21:50:41 2022
@@ -1,9 +1,21 @@
-# $NetBSD: deptgt-error.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: deptgt-error.mk,v 1.4 2022/01/22 21:50:41 rillig Exp $
 #
 # Tests for the special target .ERROR in dependency declarations, which
-# collects commands that are run when another target fails.
+# is made when another target fails.
 
-# TODO: Implementation
+all: .PHONY
+	false fails
 
-all:
-	@:;
+.ERROR:
+	@echo 'Making ${.TARGET} out of nothing.'
+
+.ERROR: sub-error
+sub-error: .PHONY
+	@echo 'Making ${.TARGET} as prerequisite.'
+
+# Before making the '.ERROR' target, these variable values are printed.
+MAKE_PRINT_VAR_ON_ERROR=	ERROR_INFO
+
+# Use single quotes to demonstrate that the output is only informational, it
+# does not use any established escaping mechanism.
+ERROR_INFO=	This information is ${:Uprinted} on 'errors'.
Index: src/usr.bin/make/unit-tests/deptgt-ignore.mk
diff -u src/usr.bin/make/unit-tests/deptgt-ignore.mk:1.3 src/usr.bin/make/unit-tests/deptgt-ignore.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt-ignore.mk:1.3	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/deptgt-ignore.mk	Sat Jan 22 21:50:41 2022
@@ -1,9 +1,31 @@
-# $NetBSD: deptgt-ignore.mk,v 1.3 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: deptgt-ignore.mk,v 1.4 2022/01/22 21:50:41 rillig Exp $
 #
 # Tests for the special target .IGNORE in dependency declarations, which
 # does not stop if a command from this target exits with a non-zero status.
+#
+# This test only applies to compatibility mode.  In jobs mode such as with
+# '-j1', all commands for a single target are bundled into a single shell
+# program, which is a different implementation technique, the .IGNORE applies
+# there as well.
+
+.MAKEFLAGS: -d0			# force stdout to be unbuffered
+
+all: depends-on-failed depends-on-ignored
+.PHONY: all depends-on-failed depends-on-ignored error-failed error-ignored
+
+error-failed error-ignored:
+	@echo '${.TARGET} before'
+	@false
+	@echo '${.TARGET} after'
+
+depends-on-failed: error-failed
+	@echo 'Making ${.TARGET} from ${.ALLSRC}.'
+depends-on-ignored: error-ignored
+	@echo 'Making ${.TARGET} from ${.ALLSRC}.'
 
-# TODO: Implementation
+# Even though the command 'false' in the middle fails, the remaining commands
+# are still run.  After that, the target is marked made, so targets depending
+# on the target with the ignored commands are made.
+.IGNORE: error-ignored
 
-all:
-	@:;
+#.MAKEFLAGS: -dg2
Index: src/usr.bin/make/unit-tests/deptgt-interrupt.mk
diff -u src/usr.bin/make/unit-tests/deptgt-interrupt.mk:1.3 

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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 21:50:42 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: cond-op-parentheses.exp
cond-op-parentheses.mk deptgt-error.exp deptgt-error.mk
deptgt-ignore.exp deptgt-ignore.mk deptgt-interrupt.exp
deptgt-interrupt.mk directive-elifndef.mk

Log Message:
tests/make: add a few more tests, mainly for special targets


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-op-parentheses.exp \
src/usr.bin/make/unit-tests/deptgt-error.mk \
src/usr.bin/make/unit-tests/deptgt-ignore.mk \
src/usr.bin/make/unit-tests/deptgt-interrupt.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op-parentheses.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/deptgt-error.exp \
src/usr.bin/make/unit-tests/deptgt-ignore.exp \
src/usr.bin/make/unit-tests/deptgt-interrupt.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-elifndef.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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 17:10:51 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: opt-debug-hash.exp opt-debug-hash.mk
opt-where-am-i.exp opt-where-am-i.mk parse.exp parse.mk
varmod-quote-dollar.exp varmod-quote-dollar.mk

Log Message:
tests/make: add a few more tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-hash.exp \
src/usr.bin/make/unit-tests/opt-debug-hash.mk \
src/usr.bin/make/unit-tests/opt-where-am-i.exp \
src/usr.bin/make/unit-tests/parse.exp \
src/usr.bin/make/unit-tests/parse.mk \
src/usr.bin/make/unit-tests/varmod-quote-dollar.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-where-am-i.mk \
src/usr.bin/make/unit-tests/varmod-quote-dollar.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-debug-hash.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.2
--- src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-hash.exp	Sat Jan 22 17:10:51 2022
@@ -1 +1,6 @@
-exit status 0
+make: "opt-debug-hash.mk" line 9: Missing argument for ".error"
+make: Fatal errors encountered -- cannot continueHashTable targets: size=16 numEntries=0 maxchain=0
+HashTable Global variables: size=16 numEntries=23 maxchain=3
+
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/opt-debug-hash.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.2
--- src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.1	Sat Sep  5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-hash.mk	Sat Jan 22 17:10:51 2022
@@ -1,10 +1,12 @@
-# $NetBSD: opt-debug-hash.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $
+# $NetBSD: opt-debug-hash.mk,v 1.2 2022/01/22 17:10:51 rillig Exp $
 #
 # Tests for the -dh command line option, which adds debug logging for
 # hash tables.  Even more detailed logging is available by compiling
 # make with -DDEBUG_HASH_LOOKUP.
 
-# TODO: Implementation
+.MAKEFLAGS: -dh
 
-all:
-	@:;
+.error
+
+# FIXME: There is a newline missing between 'continueHashTable'.
+# expect: make: Fatal errors encountered -- cannot continueHashTable targets: size=16 numEntries=0 maxchain=0
Index: src/usr.bin/make/unit-tests/opt-where-am-i.exp
diff -u src/usr.bin/make/unit-tests/opt-where-am-i.exp:1.1 src/usr.bin/make/unit-tests/opt-where-am-i.exp:1.2
--- src/usr.bin/make/unit-tests/opt-where-am-i.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/opt-where-am-i.exp	Sat Jan 22 17:10:51 2022
@@ -1 +1,4 @@
+make: Entering directory `/'
+make: Leaving directory `/'
+make: Leaving directory `'
 exit status 0
Index: src/usr.bin/make/unit-tests/parse.exp
diff -u src/usr.bin/make/unit-tests/parse.exp:1.1 src/usr.bin/make/unit-tests/parse.exp:1.2
--- src/usr.bin/make/unit-tests/parse.exp:1.1	Mon Dec 13 23:38:54 2021
+++ src/usr.bin/make/unit-tests/parse.exp	Sat Jan 22 17:10:51 2022
@@ -1,4 +1,5 @@
 make: "parse.mk" line 7: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
+make: "parse.mk" line 14: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/parse.mk
diff -u src/usr.bin/make/unit-tests/parse.mk:1.1 src/usr.bin/make/unit-tests/parse.mk:1.2
--- src/usr.bin/make/unit-tests/parse.mk:1.1	Mon Dec 13 23:38:54 2021
+++ src/usr.bin/make/unit-tests/parse.mk	Sat Jan 22 17:10:51 2022
@@ -1,7 +1,14 @@
-# $NetBSD: parse.mk,v 1.1 2021/12/13 23:38:54 rillig Exp $
+# $NetBSD: parse.mk,v 1.2 2022/01/22 17:10:51 rillig Exp $
 #
 # Test those parts of the parsing that do not belong in any of the other
 # categories.
 
 # expect+1: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
 << old
+
+# No diagnostic since the following line is parsed as a variable assignment,
+# even though the variable name is empty.  See also varname-empty.mk.
+== middle
+
+# expect+1: Makefile appears to contain unresolved CVS/RCS/??? merge conflicts
+>> new
Index: src/usr.bin/make/unit-tests/varmod-quote-dollar.exp
diff -u src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.1 src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-quote-dollar.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/varmod-quote-dollar.exp	Sat Jan 22 17:10:51 2022
@@ -1 +1,2 @@
+!"#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}~
 exit status 0

Index: src/usr.bin/make/unit-tests/opt-where-am-i.mk
diff -u src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.2 src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.3
--- src/usr.bin/make/unit-tests/opt-where-am-i.mk:1.2	Sun Aug 16 14:25:16 

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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 17:10:51 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: opt-debug-hash.exp opt-debug-hash.mk
opt-where-am-i.exp opt-where-am-i.mk parse.exp parse.mk
varmod-quote-dollar.exp varmod-quote-dollar.mk

Log Message:
tests/make: add a few more tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-hash.exp \
src/usr.bin/make/unit-tests/opt-debug-hash.mk \
src/usr.bin/make/unit-tests/opt-where-am-i.exp \
src/usr.bin/make/unit-tests/parse.exp \
src/usr.bin/make/unit-tests/parse.mk \
src/usr.bin/make/unit-tests/varmod-quote-dollar.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-where-am-i.mk \
src/usr.bin/make/unit-tests/varmod-quote-dollar.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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 16:23:56 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile directive-elifdef.mk
directive-ifmake.exp directive-ifmake.mk

Log Message:
tests/make: explore edge cases involving .ifmake


To generate a diff of this commit:
cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-elifdef.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-ifmake.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifmake.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.296 src/usr.bin/make/unit-tests/Makefile:1.297
--- src/usr.bin/make/unit-tests/Makefile:1.296	Wed Jan 19 22:10:41 2022
+++ src/usr.bin/make/unit-tests/Makefile	Sat Jan 22 16:23:56 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.296 2022/01/19 22:10:41 rillig Exp $
+# $NetBSD: Makefile,v 1.297 2022/01/22 16:23:56 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -478,7 +478,6 @@ ENV.varname-vpath+=	VPATH=varname-vpath.
 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
 # settings FLAGS.test=-dv here, since that is closer to the test code.
 FLAGS.cond-func-make=		via-cmdline
-FLAGS.directive-ifmake=		first second
 FLAGS.doterror=			# none, especially not -k
 FLAGS.jobs-error-indirect=	# none, especially not -k
 FLAGS.jobs-error-nested=	# none, especially not -k

Index: src/usr.bin/make/unit-tests/directive-elifdef.mk
diff -u src/usr.bin/make/unit-tests/directive-elifdef.mk:1.2 src/usr.bin/make/unit-tests/directive-elifdef.mk:1.3
--- src/usr.bin/make/unit-tests/directive-elifdef.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/directive-elifdef.mk	Sat Jan 22 16:23:56 2022
@@ -1,8 +1,21 @@
-# $NetBSD: directive-elifdef.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-elifdef.mk,v 1.3 2022/01/22 16:23:56 rillig Exp $
 #
-# Tests for the .elifdef directive.
+# Tests for the .elifdef directive, which is seldom used.  Instead of writing
+# '.elifdef VAR', the usual form is the more versatile '.elif defined(VAR)'.
 
-# TODO: Implementation
+# At this point, VAR is not defined, so the condition evaluates to false.
+.if 0
+.elifdef VAR
+.  error
+.endif
+
+VAR=	# defined
+
+# At this point, VAR is defined, so the condition evaluates to true.
+.if 0
+.elifdef VAR
+.else
+.  error
+.endif
 
 all:
-	@:;

Index: src/usr.bin/make/unit-tests/directive-ifmake.exp
diff -u src/usr.bin/make/unit-tests/directive-ifmake.exp:1.5 src/usr.bin/make/unit-tests/directive-ifmake.exp:1.6
--- src/usr.bin/make/unit-tests/directive-ifmake.exp:1.5	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-ifmake.exp	Sat Jan 22 16:23:56 2022
@@ -8,4 +8,8 @@ make: "directive-ifmake.mk" line 75: ok
 : first
 : second
 : late-target
-exit status 0
+make: don't know how to make !edge (continuing)
+
+Stop.
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/directive-ifmake.mk
diff -u src/usr.bin/make/unit-tests/directive-ifmake.mk:1.8 src/usr.bin/make/unit-tests/directive-ifmake.mk:1.9
--- src/usr.bin/make/unit-tests/directive-ifmake.mk:1.8	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/directive-ifmake.mk	Sat Jan 22 16:23:56 2022
@@ -1,12 +1,12 @@
-# $NetBSD: directive-ifmake.mk,v 1.8 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: directive-ifmake.mk,v 1.9 2022/01/22 16:23:56 rillig Exp $
 #
 # Tests for the .ifmake directive, which provides a shortcut for asking
 # whether a certain target is requested to be made from the command line.
 #
 # TODO: Describe why the shortcut may be useful (if it's useful at all),
-# instead of sticking to the simple '.if' only.
+# instead of using the more versatile '.if make(target)'.
 
-# The targets 'first' and 'second' are passed in on the command line.
+.MAKEFLAGS: first second
 
 # This is the most basic form.
 .ifmake first
@@ -15,9 +15,9 @@
 .  warning positive condition fails
 .endif
 
-# The not operator works as expected.
-# An alternative interpretation were that this condition is asking whether
-# the target "!first" was requested.  To distinguish this, see the next test.
+# The '!' is interpreted as 'not'.  A possible alternative interpretation of
+# this condition is whether the target named "!first" was requested.  To
+# distinguish these cases, see the next test.
 .ifmake !first
 .  warning unexpected
 .else
@@ -78,5 +78,30 @@
 .endif
 
 
-first second unmentioned late-target:
+# As an edge case, a target can actually be named "!first" on the command
+# line.  There is no way to define a target of this name though since in a
+# dependency line, a plain '!' is interpreted as a dependency operator.
+
+.MAKEFLAGS: !edge
+.ifmake edge
+.  error
+.endif
+
+# The '\!edge' in the following 

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

2022-01-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jan 22 16:23:56 UTC 2022

Modified Files:
src/usr.bin/make/unit-tests: Makefile directive-elifdef.mk
directive-ifmake.exp directive-ifmake.mk

Log Message:
tests/make: explore edge cases involving .ifmake


To generate a diff of this commit:
cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-elifdef.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/directive-ifmake.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifmake.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

2022-01-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jan 20 19:16:25 UTC 2022

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

Log Message:
tests/make: refine test for wrong diagnostic line

To trigger the faulty code path, the file where the targets gets its
first command must be included via its relative path.  That was the case
when running 'cd usr.bin/make && make test' but not when running the
tests via ATF.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep-duplicate.exp \
src/usr.bin/make/unit-tests/dep-duplicate.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-duplicate.exp
diff -u src/usr.bin/make/unit-tests/dep-duplicate.exp:1.1 src/usr.bin/make/unit-tests/dep-duplicate.exp:1.2
--- src/usr.bin/make/unit-tests/dep-duplicate.exp:1.1	Wed Jan 19 22:10:41 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.exp	Thu Jan 20 19:16:25 2022
@@ -1,4 +1,4 @@
 make: "dep-duplicate.inc" line 1: warning: duplicate script for target "all" ignored
-make: "dep-duplicate.inc" line 15: warning: using previous script for "all" defined here
-first
+make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
+main-output
 exit status 0
Index: src/usr.bin/make/unit-tests/dep-duplicate.mk
diff -u src/usr.bin/make/unit-tests/dep-duplicate.mk:1.1 src/usr.bin/make/unit-tests/dep-duplicate.mk:1.2
--- src/usr.bin/make/unit-tests/dep-duplicate.mk:1.1	Wed Jan 19 22:10:41 2022
+++ src/usr.bin/make/unit-tests/dep-duplicate.mk	Thu Jan 20 19:16:25 2022
@@ -1,21 +1,31 @@
-# $NetBSD: dep-duplicate.mk,v 1.1 2022/01/19 22:10:41 rillig Exp $
+# $NetBSD: dep-duplicate.mk,v 1.2 2022/01/20 19:16:25 rillig Exp $
 #
 # Test for a target whose commands are defined twice.  This generates a
 # warning, not an error, so ensure that the correct commands are kept.
 #
 # Also ensure that the diagnostics mention the correct file in case of
-# included files.  This particular case had been broken in parse.c 1.231 from
-# 2018-12-22.
+# included files.  Since parse.c 1.231 from 2018-12-22 and before parse.c
+# 1.653 from 2022-01-20, the wrong filename had been printed if the file of
+# the first commands section was in a file that was included by its relative
+# path.
 
-# expect: make: "dep-duplicate.inc" line 15: warning: using previous script for "all" defined here
-# FIXME: The file "dep-duplicate.inc" has no line 15.
+# expect: make: "dep-duplicate.inc" line 3: warning: using previous script for "all" defined here
+# FIXME: The file "dep-duplicate.inc" has no line 3.
 
-# expect: first
 all: .PHONY
-	@echo first
+	@exec > dep-duplicate.main; \
+	echo '# empty line 1'; \
+	echo '# empty line 2'; \
+	echo 'all:; @echo main-output'; \
+	echo '.include "dep-duplicate.inc"'
 
-_!=	echo 'all:;echo second' > dep-duplicate.inc
-.include "${.CURDIR}/dep-duplicate.inc"
+	@exec > dep-duplicate.inc; \
+	echo 'all:; @echo inc-output'
 
-.END:
+	# The main file must be specified using a relative path, just like the
+	# default 'makefile' or 'Makefile', to produce the same result when
+	# run via ATF or 'make test'.
+	@${MAKE} -r -f dep-duplicate.main
+
+	@rm -f dep-duplicate.main
 	@rm -f dep-duplicate.inc



<    1   2   3   4   5   >