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 tests/make: extend tests for parsing...
details: https://anonhg.NetBSD.org/src/rev/bb3427a99d95
branches: trunk
changeset: 1027627:bb3427a99d95
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Dec 13 23:38:54 2021 +0000
description:
tests/make: extend tests for parsing makefiles
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
usr.bin/make/unit-tests/Makefile | 3 ++-
usr.bin/make/unit-tests/dep.exp | 6 +++++-
usr.bin/make/unit-tests/dep.mk | 16 +++++++++++++---
usr.bin/make/unit-tests/depsrc.exp | 1 +
usr.bin/make/unit-tests/depsrc.mk | 14 ++++++++++----
usr.bin/make/unit-tests/deptgt-notparallel.exp | 8 ++++++++
usr.bin/make/unit-tests/deptgt-notparallel.mk | 18 +++++++++++++-----
usr.bin/make/unit-tests/deptgt-order.exp | 7 +++++++
usr.bin/make/unit-tests/deptgt-order.mk | 4 +++-
usr.bin/make/unit-tests/deptgt-path-suffix.exp | 5 ++++-
usr.bin/make/unit-tests/deptgt-path-suffix.mk | 10 +++++++++-
usr.bin/make/unit-tests/deptgt.exp | 3 +++
usr.bin/make/unit-tests/deptgt.mk | 11 ++++++++++-
usr.bin/make/unit-tests/directive.exp | 2 ++
usr.bin/make/unit-tests/directive.mk | 9 ++++++---
usr.bin/make/unit-tests/parse.exp | 4 ++++
usr.bin/make/unit-tests/parse.mk | 7 +++++++
18 files changed, 110 insertions(+), 22 deletions(-)
diffs (truncated from 303 to 300 lines):
diff -r 49a34d04f1f4 -r bb3427a99d95 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Dec 13 22:26:21 2021 +0000
+++ b/distrib/sets/lists/tests/mi Mon Dec 13 23:38:54 2021 +0000
@@ -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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/Makefile Mon Dec 13 23:38:54 2021 +0000
@@ -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-where-am-i
TESTS+= opt-x-reduce-exported
TESTS+= order
+TESTS+= parse
TESTS+= parse-var
TESTS+= phony-end
TESTS+= posix
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/dep.exp
--- a/usr.bin/make/unit-tests/dep.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/dep.exp Mon Dec 13 23:38:54 2021 +0000
@@ -1,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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/dep.mk
--- a/usr.bin/make/unit-tests/dep.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/dep.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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:
- @:;
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/depsrc.exp
--- a/usr.bin/make/unit-tests/depsrc.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/depsrc.exp Mon Dec 13 23:38:54 2021 +0000
@@ -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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/depsrc.mk
--- a/usr.bin/make/unit-tests/depsrc.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/depsrc.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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 @@
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}.
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-notparallel.exp
--- a/usr.bin/make/unit-tests/deptgt-notparallel.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-notparallel.exp Mon Dec 13 23:38:54 2021 +0000
@@ -1,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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-notparallel.mk
--- a/usr.bin/make/unit-tests/deptgt-notparallel.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-notparallel.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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.
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-order.exp
--- a/usr.bin/make/unit-tests/deptgt-order.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-order.exp Mon Dec 13 23:38:54 2021 +0000
@@ -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.'
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-order.mk
--- a/usr.bin/make/unit-tests/deptgt-order.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-order.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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 @@
# 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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-path-suffix.exp
--- a/usr.bin/make/unit-tests/deptgt-path-suffix.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-path-suffix.exp Mon Dec 13 23:38:54 2021 +0000
@@ -1,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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt-path-suffix.mk
--- a/usr.bin/make/unit-tests/deptgt-path-suffix.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt-path-suffix.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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:
@:;
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt.exp
--- a/usr.bin/make/unit-tests/deptgt.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt.exp Mon Dec 13 23:38:54 2021 +0000
@@ -9,6 +9,9 @@
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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/deptgt.mk
--- a/usr.bin/make/unit-tests/deptgt.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/deptgt.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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 @@
# 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:
@:;
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/directive.exp
--- a/usr.bin/make/unit-tests/directive.exp Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/directive.exp Mon Dec 13 23:38:54 2021 +0000
@@ -7,6 +7,8 @@
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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/directive.mk
--- a/usr.bin/make/unit-tests/directive.mk Mon Dec 13 22:26:21 2021 +0000
+++ b/usr.bin/make/unit-tests/directive.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/parse.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/parse.exp Mon Dec 13 23:38:54 2021 +0000
@@ -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
diff -r 49a34d04f1f4 -r bb3427a99d95 usr.bin/make/unit-tests/parse.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/parse.mk Mon Dec 13 23:38:54 2021 +0000
@@ -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.
Home |
Main Index |
Thread Index |
Old Index