Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make/unit-tests make(1): add tests for edge cases wh...
details: https://anonhg.NetBSD.org/src/rev/4dbb500ec71c
branches: trunk
changeset: 957059:4dbb500ec71c
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 15 11:57:00 2020 +0000
description:
make(1): add tests for edge cases when parsing directives
diffstat:
usr.bin/make/unit-tests/deptgt.exp | 8 ++++++++
usr.bin/make/unit-tests/deptgt.mk | 12 +++++++++++-
usr.bin/make/unit-tests/directive-info.exp | 4 ++++
usr.bin/make/unit-tests/directive-info.mk | 12 +++++++++++-
usr.bin/make/unit-tests/directive.exp | 5 +++++
usr.bin/make/unit-tests/directive.mk | 19 ++++++++++++++++++-
6 files changed, 57 insertions(+), 3 deletions(-)
diffs (128 lines):
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/deptgt.exp
--- a/usr.bin/make/unit-tests/deptgt.exp Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/deptgt.exp Sun Nov 15 11:57:00 2020 +0000
@@ -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
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/deptgt.mk
--- a/usr.bin/make/unit-tests/deptgt.mk Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/deptgt.mk Sun Nov 15 11:57:00 2020 +0000
@@ -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 @@
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:
@:;
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/directive-info.exp
--- a/usr.bin/make/unit-tests/directive-info.exp Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.exp Sun Nov 15 11:57:00 2020 +0000
@@ -5,6 +5,10 @@
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
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/directive-info.mk
--- a/usr.bin/make/unit-tests/directive-info.mk Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-info.mk Sun Nov 15 11:57:00 2020 +0000
@@ -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:
@:;
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/directive.exp
--- a/usr.bin/make/unit-tests/directive.exp Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/directive.exp Sun Nov 15 11:57:00 2020 +0000
@@ -2,6 +2,11 @@
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
diff -r 94df3bc47c14 -r 4dbb500ec71c usr.bin/make/unit-tests/directive.mk
--- a/usr.bin/make/unit-tests/directive.mk Sun Nov 15 10:11:26 2020 +0000
+++ b/usr.bin/make/unit-tests/directive.mk Sun Nov 15 11:57:00 2020 +0000
@@ -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:
@:;
Home |
Main Index |
Thread Index |
Old Index