Module Name:    src
Committed By:   rillig
Date:           Mon Dec 13 23:38:55 UTC 2021

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile dep.exp dep.mk depsrc.exp
            depsrc.mk deptgt-notparallel.exp deptgt-notparallel.mk
            deptgt-order.exp deptgt-order.mk deptgt-path-suffix.exp
            deptgt-path-suffix.mk deptgt.exp deptgt.mk directive.exp
            directive.mk
Added Files:
        src/usr.bin/make/unit-tests: parse.exp parse.mk

Log Message:
tests/make: extend tests for parsing makefiles


To generate a diff of this commit:
cvs rdiff -u -r1.1176 -r1.1177 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.288 -r1.289 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/dep.exp \
    src/usr.bin/make/unit-tests/deptgt-notparallel.exp \
    src/usr.bin/make/unit-tests/deptgt-path-suffix.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep.mk \
    src/usr.bin/make/unit-tests/depsrc.exp \
    src/usr.bin/make/unit-tests/deptgt-notparallel.mk \
    src/usr.bin/make/unit-tests/deptgt-order.exp \
    src/usr.bin/make/unit-tests/deptgt-path-suffix.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc.mk \
    src/usr.bin/make/unit-tests/directive.exp \
    src/usr.bin/make/unit-tests/directive.mk
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-order.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/deptgt.mk
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/parse.exp \
    src/usr.bin/make/unit-tests/parse.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1176 src/distrib/sets/lists/tests/mi:1.1177
--- src/distrib/sets/lists/tests/mi:1.1176	Sun Dec 12 22:16:48 2021
+++ src/distrib/sets/lists/tests/mi	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1176 2021/12/12 22:16:48 rillig Exp $
+# $NetBSD: mi,v 1.1177 2021/12/13 23:38:54 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5839,6 +5839,8 @@
 ./usr/tests/usr.bin/make/unit-tests/order.mk					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/parse-var.exp				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/parse-var.mk				tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/parse.exp					tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/parse.mk					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/phony-end.exp				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/phony-end.mk				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/posix.exp					tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.288 src/usr.bin/make/unit-tests/Makefile:1.289
--- src/usr.bin/make/unit-tests/Makefile:1.288	Sun Dec 12 22:16:48 2021
+++ src/usr.bin/make/unit-tests/Makefile	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.288 2021/12/12 22:16:48 rillig Exp $
+# $NetBSD: Makefile,v 1.289 2021/12/13 23:38:54 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -278,6 +278,7 @@ TESTS+=		opt-warnings-as-errors
 TESTS+=		opt-where-am-i
 TESTS+=		opt-x-reduce-exported
 TESTS+=		order
+TESTS+=		parse
 TESTS+=		parse-var
 TESTS+=		phony-end
 TESTS+=		posix

Index: src/usr.bin/make/unit-tests/dep.exp
diff -u src/usr.bin/make/unit-tests/dep.exp:1.1 src/usr.bin/make/unit-tests/dep.exp:1.2
--- src/usr.bin/make/unit-tests/dep.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/dep.exp	Mon Dec 13 23:38:54 2021
@@ -1 +1,5 @@
-exit status 0
+make: "dep.mk" line 11: Inconsistent operator for only-colon
+make: "dep.mk" line 13: Inconsistent operator for only-colon
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/deptgt-notparallel.exp
diff -u src/usr.bin/make/unit-tests/deptgt-notparallel.exp:1.1 src/usr.bin/make/unit-tests/deptgt-notparallel.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-notparallel.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/deptgt-notparallel.exp	Mon Dec 13 23:38:54 2021
@@ -1 +1,9 @@
+: Making 1 out of nothing.
+: Making 2 out of nothing.
+: Making 3 out of nothing.
+: Making 4 out of nothing.
+: Making 5 out of nothing.
+: Making 6 out of nothing.
+: Making 7 out of nothing.
+: Making 8 out of nothing.
 exit status 0
Index: src/usr.bin/make/unit-tests/deptgt-path-suffix.exp
diff -u src/usr.bin/make/unit-tests/deptgt-path-suffix.exp:1.1 src/usr.bin/make/unit-tests/deptgt-path-suffix.exp:1.2
--- src/usr.bin/make/unit-tests/deptgt-path-suffix.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/deptgt-path-suffix.exp	Mon Dec 13 23:38:54 2021
@@ -1 +1,4 @@
-exit status 0
+make: "deptgt-path-suffix.mk" line 8: Suffix '.c' not defined (yet)
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1

Index: src/usr.bin/make/unit-tests/dep.mk
diff -u src/usr.bin/make/unit-tests/dep.mk:1.2 src/usr.bin/make/unit-tests/dep.mk:1.3
--- src/usr.bin/make/unit-tests/dep.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/dep.mk	Mon Dec 13 23:38:54 2021
@@ -1,8 +1,18 @@
-# $NetBSD: dep.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: dep.mk,v 1.3 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for dependency declarations, such as "target: sources".
 
-# TODO: Implementation
+.MAIN: all
+
+# As soon as a target is defined using one of the dependency operators, it is
+# restricted to this dependency operator and cannot use the others anymore.
+only-colon:
+# expect+1: Inconsistent operator for only-colon
+only-colon!
+# expect+1: Inconsistent operator for only-colon
+only-colon::
+# Ensure that the target still has the original operator.  If it hadn't, there
+# would be another error message.
+only-colon:
 
 all:
-	@:;
Index: src/usr.bin/make/unit-tests/depsrc.exp
diff -u src/usr.bin/make/unit-tests/depsrc.exp:1.2 src/usr.bin/make/unit-tests/depsrc.exp:1.3
--- src/usr.bin/make/unit-tests/depsrc.exp:1.2	Tue Dec 22 19:38:44 2020
+++ src/usr.bin/make/unit-tests/depsrc.exp	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,5 @@
 : 'Undefined variables are expanded directly in the dependency'
 : 'declaration.  They are not preserved and maybe expanded later.'
 : 'This is in contrast to local variables such as ${.TARGET}.'
+: Making .UNKNOWN from nothing.
 exit status 0
Index: src/usr.bin/make/unit-tests/deptgt-notparallel.mk
diff -u src/usr.bin/make/unit-tests/deptgt-notparallel.mk:1.2 src/usr.bin/make/unit-tests/deptgt-notparallel.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-notparallel.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/deptgt-notparallel.mk	Mon Dec 13 23:38:54 2021
@@ -1,8 +1,16 @@
-# $NetBSD: deptgt-notparallel.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: deptgt-notparallel.mk,v 1.3 2021/12/13 23:38:54 rillig Exp $
 #
-# Tests for the special target .NOTPARALLEL in dependency declarations.
+# Tests for the special target .NOTPARALLEL in dependency declarations, which
+# prevents the job module from doing anything in parallel, by setting the
+# maximum jobs to 1.  This only applies to the current make, it is not
+# exported to submakes.
 
-# TODO: Implementation
+.MAKEFLAGS: -j4
 
-all:
-	@:;
+# Set opts.maxJobs back to 1.  Without this line, the output would be in
+# random order, interleaved with separators like '--- 1 ---'.
+.NOTPARALLEL:
+
+all: 1 2 3 4 5 6 7 8
+1 2 3 4 5 6 7 8: .PHONY
+	: Making ${.TARGET} out of nothing.
Index: src/usr.bin/make/unit-tests/deptgt-order.exp
diff -u src/usr.bin/make/unit-tests/deptgt-order.exp:1.2 src/usr.bin/make/unit-tests/deptgt-order.exp:1.3
--- src/usr.bin/make/unit-tests/deptgt-order.exp:1.2	Thu Jun 17 15:25:33 2021
+++ src/usr.bin/make/unit-tests/deptgt-order.exp	Mon Dec 13 23:38:54 2021
@@ -1,3 +1,10 @@
+ParseReadLine (15): '.ORDER: three one'
+ParseDependency(.ORDER: three one)
+# ParseDependencySourceOrder: added Order dependency three - one
+# three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none
+# one, unmade, type OP_DEPENDS|OP_PHONY, flags none
+ParseReadLine (16): '.MAKEFLAGS: -d0'
+ParseDependency(.MAKEFLAGS: -d0)
 : 'Making two out of one.'
 : 'Making three out of two.'
 : 'Making all out of three.'
Index: src/usr.bin/make/unit-tests/deptgt-path-suffix.mk
diff -u src/usr.bin/make/unit-tests/deptgt-path-suffix.mk:1.2 src/usr.bin/make/unit-tests/deptgt-path-suffix.mk:1.3
--- src/usr.bin/make/unit-tests/deptgt-path-suffix.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/deptgt-path-suffix.mk	Mon Dec 13 23:38:54 2021
@@ -1,8 +1,16 @@
-# $NetBSD: deptgt-path-suffix.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: deptgt-path-suffix.mk,v 1.3 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for the special target .PATH.suffix in dependency declarations.
 
 # TODO: Implementation
 
+# expect+1: Suffix '.c' not defined (yet)
+.PATH.c: ..
+
+.SUFFIXES: .c
+
+# Now the suffix is defined, and the path is recorded.
+.PATH.c: ..
+
 all:
 	@:;

Index: src/usr.bin/make/unit-tests/depsrc.mk
diff -u src/usr.bin/make/unit-tests/depsrc.mk:1.4 src/usr.bin/make/unit-tests/depsrc.mk:1.5
--- src/usr.bin/make/unit-tests/depsrc.mk:1.4	Tue Dec 22 19:38:44 2020
+++ src/usr.bin/make/unit-tests/depsrc.mk	Mon Dec 13 23:38:54 2021
@@ -1,7 +1,7 @@
-# $NetBSD: depsrc.mk,v 1.4 2020/12/22 19:38:44 rillig Exp $
+# $NetBSD: depsrc.mk,v 1.5 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for special sources (those starting with a dot, followed by
-# uppercase letters) in dependency declarations, such as .PHONY.
+# uppercase letters) in dependency declarations, such as '.PHONY'.
 
 # TODO: Implementation
 
@@ -14,13 +14,19 @@ target: .PHONY source-${DEFINED_LATER}
 DEFINED_LATER=	later
 #
 source-: .PHONY
+	# This section applies.
 	: 'Undefined variables are expanded directly in the dependency'
 	: 'declaration.  They are not preserved and maybe expanded later.'
 	: 'This is in contrast to local variables such as $${.TARGET}.'
 source-later: .PHONY
+	# This section doesn't apply.
 	: 'Undefined variables are tried to be expanded in a dependency'
 	: 'declaration.  If that fails because the variable is undefined,'
 	: 'the expression is preserved and tried to be expanded later.'
 
-all:
-	@:;
+# Sources that look like keywords but are not known are interpreted as
+# ordinary sources.
+target: .UNKNOWN
+
+.UNKNOWN:
+	: Making ${.TARGET} from ${.ALLSRC:S,^$,nothing,W}.
Index: src/usr.bin/make/unit-tests/directive.exp
diff -u src/usr.bin/make/unit-tests/directive.exp:1.4 src/usr.bin/make/unit-tests/directive.exp:1.5
--- src/usr.bin/make/unit-tests/directive.exp:1.4	Mon Apr  5 13:35:41 2021
+++ src/usr.bin/make/unit-tests/directive.exp	Mon Dec 13 23:38:54 2021
@@ -7,6 +7,8 @@ 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: "directive.mk" line 35: Invalid line type
+make: "directive.mk" line 38: 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.mk
diff -u src/usr.bin/make/unit-tests/directive.mk:1.4 src/usr.bin/make/unit-tests/directive.mk:1.5
--- src/usr.bin/make/unit-tests/directive.mk:1.4	Sun Nov 15 11:57:00 2020
+++ src/usr.bin/make/unit-tests/directive.mk	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: directive.mk,v 1.4 2020/11/15 11:57:00 rillig Exp $
+# $NetBSD: directive.mk,v 1.5 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for the preprocessing directives, such as .if or .info.
 
@@ -31,5 +31,8 @@
 # Not even the space after the '.info' can change anything about this.
 .${:Uinfo} : source
 
-all:
-	@:;
+# expect+1: Invalid line type
+target-without-colon
+
+# expect+1: Invalid line type
+target-without-colon another-target

Index: src/usr.bin/make/unit-tests/deptgt-order.mk
diff -u src/usr.bin/make/unit-tests/deptgt-order.mk:1.3 src/usr.bin/make/unit-tests/deptgt-order.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt-order.mk:1.3	Thu Jun 17 15:25:33 2021
+++ src/usr.bin/make/unit-tests/deptgt-order.mk	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt-order.mk,v 1.3 2021/06/17 15:25:33 rillig Exp $
+# $NetBSD: deptgt-order.mk,v 1.4 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for the special target .ORDER in dependency declarations.
 
@@ -11,7 +11,9 @@ three: two
 
 # This .ORDER creates a circular dependency since 'three' depends on 'one'
 # but 'one' is supposed to be built after 'three'.
+.MAKEFLAGS: -dp
 .ORDER: three one
+.MAKEFLAGS: -d0
 
 # XXX: The circular dependency should be detected here.
 all: three

Index: src/usr.bin/make/unit-tests/deptgt.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.8 src/usr.bin/make/unit-tests/deptgt.exp:1.9
--- src/usr.bin/make/unit-tests/deptgt.exp:1.8	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/unit-tests/deptgt.exp	Mon Dec 13 23:38:54 2021
@@ -9,6 +9,9 @@ ParseReadLine (37): '	: command for empt
 ParseReadLine (38): '.MAKEFLAGS: -d0'
 ParseDependency(.MAKEFLAGS: -d0)
 make: "deptgt.mk" line 46: Unknown modifier "Z"
+make: "deptgt.mk" line 49: warning: Extra target ignored
+make: "deptgt.mk" line 52: warning: Extra target (ordinary) ignored
+make: "deptgt.mk" line 55: warning: Special and mundane targets don't mix. Mundane ones ignored
 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.11 src/usr.bin/make/unit-tests/deptgt.mk:1.12
--- src/usr.bin/make/unit-tests/deptgt.mk:1.11	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/unit-tests/deptgt.mk	Mon Dec 13 23:38:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.11 2021/04/04 10:13:09 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.12 2021/12/13 23:38:54 rillig Exp $
 #
 # Tests for special targets like .BEGIN or .SUFFIXES in dependency
 # declarations.
@@ -45,5 +45,14 @@ ${:U}: empty-source
 # that nobody uses it.
 $$$$$$$${:U:Z}:
 
+# expect+1: warning: Extra target ignored
+.END ordinary:
+
+# expect+1: warning: Extra target (ordinary) ignored
+.PATH ordinary:
+
+# expect+1: Special and mundane targets don't mix. Mundane ones ignored
+ordinary .PATH:
+
 all:
 	@:;

Added files:

Index: src/usr.bin/make/unit-tests/parse.exp
diff -u /dev/null src/usr.bin/make/unit-tests/parse.exp:1.1
--- /dev/null	Mon Dec 13 23:38:55 2021
+++ src/usr.bin/make/unit-tests/parse.exp	Mon Dec 13 23:38:54 2021
@@ -0,0 +1,4 @@
+make: "parse.mk" line 7: 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 /dev/null src/usr.bin/make/unit-tests/parse.mk:1.1
--- /dev/null	Mon Dec 13 23:38:55 2021
+++ src/usr.bin/make/unit-tests/parse.mk	Mon Dec 13 23:38:54 2021
@@ -0,0 +1,7 @@
+# $NetBSD: parse.mk,v 1.1 2021/12/13 23:38:54 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

Reply via email to