Module Name: src
Committed By: rillig
Date: Sun Nov 15 11:57:01 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: deptgt.exp deptgt.mk directive-info.exp
directive-info.mk directive.exp directive.mk
Log Message:
make(1): add tests for edge cases when parsing directives
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-info.exp \
src/usr.bin/make/unit-tests/directive.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-info.mk \
src/usr.bin/make/unit-tests/directive.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.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.4 src/usr.bin/make/unit-tests/deptgt.exp:1.5
--- src/usr.bin/make/unit-tests/deptgt.exp:1.4 Mon Sep 14 18:27:15 2020
+++ src/usr.bin/make/unit-tests/deptgt.exp Sun Nov 15 11:57:00 2020
@@ -1,5 +1,13 @@
make: "deptgt.mk" line 10: warning: Extra target ignored
make: "deptgt.mk" line 28: Unassociated shell command ": command3 # parse error, since targets == NULL"
+ParseReadLine (34): '${:U}: empty-source'
+ParseDoDependency(: empty-source)
+ParseReadLine (35): ' : command for empty targets list'
+ParseReadLine (36): ': empty-source'
+ParseDoDependency(: empty-source)
+ParseReadLine (37): ' : command for empty targets list'
+ParseReadLine (38): '.MAKEFLAGS: -d0'
+ParseDoDependency(.MAKEFLAGS: -d0)
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.8 src/usr.bin/make/unit-tests/deptgt.mk:1.9
--- src/usr.bin/make/unit-tests/deptgt.mk:1.8 Sun Oct 18 13:02:10 2020
+++ src/usr.bin/make/unit-tests/deptgt.mk Sun Nov 15 11:57:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.8 2020/10/18 13:02:10 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.9 2020/11/15 11:57:00 rillig Exp $
#
# Tests for special targets like .BEGIN or .SUFFIXES in dependency
# declarations.
@@ -27,5 +27,15 @@ target1 target2: sources # targets := [t
VAR=value # targets := NULL
: command3 # parse error, since targets == NULL
+# In a dependency declaration, the list of targets can be empty.
+# It doesn't matter whether the empty string is generated by a variable
+# expression or whether it is just omitted.
+.MAKEFLAGS: -dp
+${:U}: empty-source
+ : command for empty targets list
+: empty-source
+ : command for empty targets list
+.MAKEFLAGS: -d0
+
all:
@:;
Index: src/usr.bin/make/unit-tests/directive-info.exp
diff -u src/usr.bin/make/unit-tests/directive-info.exp:1.2 src/usr.bin/make/unit-tests/directive-info.exp:1.3
--- src/usr.bin/make/unit-tests/directive-info.exp:1.2 Tue Nov 3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive-info.exp Sun Nov 15 11:57:00 2020
@@ -5,6 +5,10 @@ make: "directive-info.mk" line 10: messa
make: "directive-info.mk" line 11: indented message
make: "directive-info.mk" line 12: Unknown directive "information"
make: "directive-info.mk" line 13: message
+make: "directive-info.mk" line 18: Unknown directive "info"
+make: "directive-info.mk" line 19: Unknown directive "info"
+make: "directive-info.mk" line 22: Unknown directive "info-message"
+make: "directive-info.mk" line 23: no-target: no-source
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive.exp
diff -u src/usr.bin/make/unit-tests/directive.exp:1.2 src/usr.bin/make/unit-tests/directive.exp:1.3
--- src/usr.bin/make/unit-tests/directive.exp:1.2 Tue Nov 3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive.exp Sun Nov 15 11:57:00 2020
@@ -2,6 +2,11 @@ make: "directive.mk" line 9: Unknown dir
make: "directive.mk" line 10: Unknown directive "indented"
make: "directive.mk" line 11: Unknown directive "indented"
make: "directive.mk" line 15: Unknown directive "info"
+Global:.info =
+Global:.info = value
+make: "directive.mk" line 26: := value
+Global:.MAKEFLAGS = -r -k -d v -d
+Global:.MAKEFLAGS = -r -k -d v -d 0
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/directive-info.mk
diff -u src/usr.bin/make/unit-tests/directive-info.mk:1.3 src/usr.bin/make/unit-tests/directive-info.mk:1.4
--- src/usr.bin/make/unit-tests/directive-info.mk:1.3 Tue Nov 3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive-info.mk Sun Nov 15 11:57:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-info.mk,v 1.3 2020/11/03 17:17:31 rillig Exp $
+# $NetBSD: directive-info.mk,v 1.4 2020/11/15 11:57:00 rillig Exp $
#
# Tests for the .info directive.
@@ -13,5 +13,15 @@
.information message # oops: misspelled
.info.man: # not a message, but possibly a suffix rule
+# Even if lines would have trailing whitespace, this would be trimmed by
+# ParseGetLine.
+.info
+.info # comment
+
+.info: message # This is a dependency declaration.
+.info-message # This is an unknown directive.
+.info no-target: no-source # This is a .info directive, not a dependency.
+# See directive.mk for more tests of this kind.
+
all:
@:;
Index: src/usr.bin/make/unit-tests/directive.mk
diff -u src/usr.bin/make/unit-tests/directive.mk:1.3 src/usr.bin/make/unit-tests/directive.mk:1.4
--- src/usr.bin/make/unit-tests/directive.mk:1.3 Tue Nov 3 17:17:31 2020
+++ src/usr.bin/make/unit-tests/directive.mk Sun Nov 15 11:57:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive.mk,v 1.3 2020/11/03 17:17:31 rillig Exp $
+# $NetBSD: directive.mk,v 1.4 2020/11/15 11:57:00 rillig Exp $
#
# Tests for the preprocessing directives, such as .if or .info.
@@ -14,5 +14,22 @@
# expressions.
.${:Uinfo} directives cannot be indirect
+# There is no directive called '.target', therefore this is parsed as a
+# dependency declaration with 2 targets and 1 source.
+.target target: source
+
+# This looks ambiguous. It could be either an .info message or a variable
+# assignment. It is a variable assignment.
+.MAKEFLAGS: -dv
+.info:= value
+.info?= value # This is a variable assignment as well.
+.info := value # The space after the '.info' makes this
+ # a directive.
+.MAKEFLAGS: -d0
+
+# This is a dependency since directives must be given directly.
+# Not even the space after the '.info' can change anything about this.
+.${:Uinfo} : source
+
all:
@:;