aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/opt-debug-file.mk
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bmake/unit-tests/opt-debug-file.mk')
-rw-r--r--contrib/bmake/unit-tests/opt-debug-file.mk32
1 files changed, 24 insertions, 8 deletions
diff --git a/contrib/bmake/unit-tests/opt-debug-file.mk b/contrib/bmake/unit-tests/opt-debug-file.mk
index b878c2bcf734..d107f177dae3 100644
--- a/contrib/bmake/unit-tests/opt-debug-file.mk
+++ b/contrib/bmake/unit-tests/opt-debug-file.mk
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-file.mk,v 1.8 2022/01/11 19:47:34 rillig Exp $
+# $NetBSD: opt-debug-file.mk,v 1.12 2025/07/06 08:48:34 rillig Exp $
#
# Tests for the -dF command line option, which redirects the debug log
# to a file instead of writing it to stderr.
@@ -18,7 +18,7 @@ VAR= value ${:Uexpanded}
# Make sure that the debug logging file contains some logging.
DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!}
# Grmbl. Because of the := operator in the above line, the variable
-# value contains ${:Uexpanded}. This variable expression is expanded
+# value contains ${:Uexpanded}. This expression is expanded
# when it is used in the condition below. Therefore, be careful when storing
# untrusted input in variables.
#.MAKEFLAGS: -dc -dFstderr
@@ -27,7 +27,9 @@ DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!}
.endif
# To get the unexpanded text that was actually written to the debug log
-# file, the content of that log file must not be stored in a variable.
+# file, the content of that log file must not be stored in a variable
+# directly. Instead, it can be processed in a single expression by a chain
+# of modifiers.
#
# XXX: In the :M modifier, a dollar is escaped using '$$', not '\$'. This
# escaping scheme unnecessarily differs from all other modifiers.
@@ -35,15 +37,26 @@ DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!}
. error
.endif
+# To get the unexpanded text that was actually written to the debug log
+# file, the content of that log file must not be stored in a variable
+# directly. Instead, each dollar sign must be escaped first.
+DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!:S,\$,\$\$,g}
+.if ${DEBUG_OUTPUT:M*Uexpanded*} != "\${:Uexpanded}"
+. error
+.endif
+
.MAKEFLAGS: -d0
# See Parse_Error.
.MAKEFLAGS: -dFstdout
+# expect+1: This goes to stderr only, once.
. info This goes to stderr only, once.
.MAKEFLAGS: -dFstderr
+# expect+1: This goes to stderr only, once.
. info This goes to stderr only, once.
.MAKEFLAGS: -dFopt-debug-file.debuglog
+# expect+1: This goes to stderr, and in addition to the debug log.
. info This goes to stderr, and in addition to the debug log.
.MAKEFLAGS: -dFstderr -d0c
.if ${:!cat opt-debug-file.debuglog!:Maddition:[#]} != 1
@@ -51,15 +64,18 @@ DEBUG_OUTPUT:= ${:!cat opt-debug-file.debuglog!}
.endif
-# See ApplyModifier_Subst, which calls Error.
+# See Main_ParseArgLine, which calls Error.
.MAKEFLAGS: -dFstdout
-: This goes to stderr only, once. ${:U:S
+# expect: make: Unterminated quoted string [make 'This goes to stdout only, once.]
+.MAKEFLAGS: 'This goes to stdout only, once.
.MAKEFLAGS: -dFstderr
-: This goes to stderr only, once. ${:U:S
+# expect: make: Unterminated quoted string [make 'This goes to stderr only, once.]
+.MAKEFLAGS: 'This goes to stderr only, once.
.MAKEFLAGS: -dFopt-debug-file.debuglog
-: This goes to stderr, and in addition to the debug log. ${:U:S
+# expect: make: Unterminated quoted string [make 'This goes to stderr, and in addition to the debug log.]
+.MAKEFLAGS: 'This goes to stderr, and in addition to the debug log.
.MAKEFLAGS: -dFstderr -d0c
-.if ${:!cat opt-debug-file.debuglog!:Mdelimiter:[#]} != 1
+.if ${:!cat opt-debug-file.debuglog!:MUnterminated:[#]} != 1
. error
.endif