Module Name:    src
Committed By:   rillig
Date:           Fri Sep 25 20:11:06 UTC 2020

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

Log Message:
make(1): add test for make() function in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/cond-func-make.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-func-make.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/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.150 src/usr.bin/make/unit-tests/Makefile:1.151
--- src/usr.bin/make/unit-tests/Makefile:1.150	Fri Sep 25 18:18:25 2020
+++ src/usr.bin/make/unit-tests/Makefile	Fri Sep 25 20:11:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.150 2020/09/25 18:18:25 rillig Exp $
+# $NetBSD: Makefile,v 1.151 2020/09/25 20:11:06 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -362,6 +362,7 @@ ENV.varmisc+=		FROM_ENV_AFTER=env
 # Override make flags for some of the tests; default is -k.
 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
 # settings FLAGS.test=-dv here, since that is closer to the test code.
+FLAGS.cond-func-make=	via-cmdline
 FLAGS.directive-ifmake=	first second
 FLAGS.doterror=		# none
 FLAGS.envfirst=		-e

Index: src/usr.bin/make/unit-tests/cond-func-make.exp
diff -u src/usr.bin/make/unit-tests/cond-func-make.exp:1.1 src/usr.bin/make/unit-tests/cond-func-make.exp:1.2
--- src/usr.bin/make/unit-tests/cond-func-make.exp:1.1	Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/cond-func-make.exp	Fri Sep 25 20:11:06 2020
@@ -1 +1,3 @@
+: via-cmdline
+: via-dot-makeflags
 exit status 0

Index: src/usr.bin/make/unit-tests/cond-func-make.mk
diff -u src/usr.bin/make/unit-tests/cond-func-make.mk:1.2 src/usr.bin/make/unit-tests/cond-func-make.mk:1.3
--- src/usr.bin/make/unit-tests/cond-func-make.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/cond-func-make.mk	Fri Sep 25 20:11:06 2020
@@ -1,8 +1,24 @@
-# $NetBSD: cond-func-make.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: cond-func-make.mk,v 1.3 2020/09/25 20:11:06 rillig Exp $
 #
-# Tests for the make() function in .if conditions.
+# Tests for the make() function in .if conditions, which tests whether
+# the argument has been passed as a target via the command line or later
+# via the .MAKEFLAGS special dependency target.
 
-# TODO: Implementation
+.if !make(via-cmdline)
+.  error
+.endif
+.if make(via-dot-makeflags)
+.  error
+.endif
 
-all:
-	@:;
+.MAKEFLAGS: via-dot-makeflags
+
+.if !make(via-cmdline)
+.  error
+.endif
+.if !make(via-dot-makeflags)
+.  error
+.endif
+
+via-cmdline via-dot-makeflags:
+	: $@

Reply via email to