Module Name:    src
Committed By:   rillig
Date:           Wed Aug  7 05:37:11 UTC 2024

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

Log Message:
tests/make: demonstrate unintended parsing of words in conditions

A word is not supposed to include its trailing space, as it doesn't
contain its leading space either.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-func.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func.mk \
    src/usr.bin/make/unit-tests/directive-include-guard.mk
cvs rdiff -u -r1.14 -r1.15 \
    src/usr.bin/make/unit-tests/directive-include-guard.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/cond-func.exp
diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.11 src/usr.bin/make/unit-tests/cond-func.exp:1.12
--- src/usr.bin/make/unit-tests/cond-func.exp:1.11	Tue Aug  6 17:46:01 2024
+++ src/usr.bin/make/unit-tests/cond-func.exp	Wed Aug  7 05:37:11 2024
@@ -7,6 +7,7 @@ make: "cond-func.mk" line 115: A plain f
 make: "cond-func.mk" line 126: Symbols may start with a function name.
 make: "cond-func.mk" line 132: Symbols may start with a function name.
 make: "cond-func.mk" line 138: Missing ')' after argument '' for 'defined'
+make: "cond-func.mk" line 146: Missing ')' after argument 'VARNAME.param' for 'defined'
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-func.mk
diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.16 src/usr.bin/make/unit-tests/cond-func.mk:1.17
--- src/usr.bin/make/unit-tests/cond-func.mk:1.16	Tue Aug  6 17:46:01 2024
+++ src/usr.bin/make/unit-tests/cond-func.mk	Wed Aug  7 05:37:11 2024
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func.mk,v 1.16 2024/08/06 17:46:01 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.17 2024/08/07 05:37:11 rillig Exp $
 #
 # Tests for those parts of the functions in .if conditions that are common
 # among several functions.
@@ -140,3 +140,11 @@ defined-var=	# defined but empty
 .else
 .  error
 .endif
+
+# XXX: Don't use the expanded argument in the diagnostic.
+# expect+1: Missing ')' after argument 'VARNAME.param' for 'defined'
+.if defined(${:UVARNAME}.param extra)
+.  error
+.else
+.  error
+.endif
Index: src/usr.bin/make/unit-tests/directive-include-guard.mk
diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.16 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.17
--- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.16	Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.mk	Wed Aug  7 05:37:11 2024
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include-guard.mk,v 1.16 2023/12/17 14:07:22 rillig Exp $
+# $NetBSD: directive-include-guard.mk,v 1.17 2024/08/07 05:37:11 rillig Exp $
 #
 # Tests for multiple-inclusion guards in makefiles.
 #
@@ -583,13 +583,21 @@ LINES.target-name-exclamation= \
 
 # If the guard target name is enclosed in spaces, it does not have an effect,
 # as that form is not common in practice.
-CASES+=	target-name-parenthesized
-LINES.target-name-parenthesized= \
-	'.if !target( target-name-parenthesized )' \
-	'target-name-parenthesized: .NOTMAIN' \
+CASES+=	target-name-leading-space
+LINES.target-name-leading-space= \
+	'.if !target( target-name-leading-space)' \
+	'target-name-leading-space: .NOTMAIN' \
+	'.endif'
+# expect: Parse_PushInput: file target-name-leading-space.tmp, line 1
+# expect: Parse_PushInput: file target-name-leading-space.tmp, line 1
+
+CASES+=	target-name-trailing-space
+LINES.target-name-trailing-space= \
+	'.if !target(target-name-trailing-space )' \
+	'target-name-trailing-space: .NOTMAIN' \
 	'.endif'
-# expect: Parse_PushInput: file target-name-parenthesized.tmp, line 1
-# expect: Parse_PushInput: file target-name-parenthesized.tmp, line 1
+# expect: Parse_PushInput: file target-name-trailing-space.tmp, line 1
+# expect: Skipping 'target-name-trailing-space.tmp' because 'target-name-trailing-space' is defined
 
 # If the guard target condition is enclosed in parentheses, it does not have
 # an effect, as that form is not common in practice.

Index: src/usr.bin/make/unit-tests/directive-include-guard.exp
diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.14 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.15
--- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.14	Sun Dec 17 14:07:22 2023
+++ src/usr.bin/make/unit-tests/directive-include-guard.exp	Wed Aug  7 05:37:11 2024
@@ -95,8 +95,10 @@ Parse_PushInput: file target-already-def
 Skipping 'target-already-defined.tmp' because 'target-already-defined' is defined
 Parse_PushInput: file target-name-exclamation.tmp, line 1
 Parse_PushInput: file target-name-exclamation.tmp, line 1
-Parse_PushInput: file target-name-parenthesized.tmp, line 1
-Parse_PushInput: file target-name-parenthesized.tmp, line 1
+Parse_PushInput: file target-name-leading-space.tmp, line 1
+Parse_PushInput: file target-name-leading-space.tmp, line 1
+Parse_PushInput: file target-name-trailing-space.tmp, line 1
+Skipping 'target-name-trailing-space.tmp' because 'target-name-trailing-space' is defined
 Parse_PushInput: file target-call-parenthesized.tmp, line 1
 Parse_PushInput: file target-call-parenthesized.tmp, line 1
 Parse_PushInput: file multiline.tmp, line 1

Reply via email to