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 test for the .ifmake di...



details:   https://anonhg.NetBSD.org/src/rev/2a2acd9b1550
branches:  trunk
changeset: 975495:2a2acd9b1550
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 29 19:07:32 2020 +0000

description:
make(1): add test for the .ifmake directive

diffstat:

 usr.bin/make/unit-tests/Makefile             |   3 +-
 usr.bin/make/unit-tests/directive-ifmake.exp |   7 ++++
 usr.bin/make/unit-tests/directive-ifmake.mk  |  47 +++++++++++++++++++++++++--
 3 files changed, 51 insertions(+), 6 deletions(-)

diffs (83 lines):

diff -r 148158f49d86 -r 2a2acd9b1550 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Aug 29 19:06:32 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sat Aug 29 19:07:32 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.127 2020/08/29 18:50:25 rillig Exp $
+# $NetBSD: Makefile,v 1.128 2020/08/29 19:07:32 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -329,6 +329,7 @@
 # settings FLAGS.test=-dv here, since that is closer to the test code.
 FLAGS.archive=         -dA
 FLAGS.counter=         -dv
+FLAGS.directive-ifmake=        first second
 FLAGS.doterror=                # none
 FLAGS.envfirst=                -e
 FLAGS.export=          # none
diff -r 148158f49d86 -r 2a2acd9b1550 usr.bin/make/unit-tests/directive-ifmake.exp
--- a/usr.bin/make/unit-tests/directive-ifmake.exp      Sat Aug 29 19:06:32 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifmake.exp      Sat Aug 29 19:07:32 2020 +0000
@@ -1,1 +1,8 @@
+make: "directive-ifmake.mk" line 8: ok: positive condition works
+make: "directive-ifmake.mk" line 19: ok: negation works
+make: "directive-ifmake.mk" line 25: ok: double negation works
+make: "directive-ifmake.mk" line 32: ok: both mentioned
+make: "directive-ifmake.mk" line 39: ok: only those mentioned
+: first
+: second
 exit status 0
diff -r 148158f49d86 -r 2a2acd9b1550 usr.bin/make/unit-tests/directive-ifmake.mk
--- a/usr.bin/make/unit-tests/directive-ifmake.mk       Sat Aug 29 19:06:32 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifmake.mk       Sat Aug 29 19:07:32 2020 +0000
@@ -1,8 +1,45 @@
-# $NetBSD: directive-ifmake.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-ifmake.mk,v 1.3 2020/08/29 19:07:32 rillig Exp $
 #
-# Tests for the .ifmake directive.
+# Tests for the .ifmake directive, which provides a shortcut for asking
+# whether a certain target is requested to be made from the command line.
+
+# This is the most basic form.
+.ifmake first
+.info ok: positive condition works
+.else
+.warning positive condition fails
+.endif
+
+# The not operator works as expected.
+# An alternative interpretation were that this condition is asking whether
+# the target "!first" was requested.  To distinguish this, see the next test.
+.ifmake !first
+.warning unexpected
+.else
+.info ok: negation works
+.endif
 
-# TODO: Implementation
+# See if the exclamation mark really means "not", or if it is just part of
+# the target name.
+.ifmake !!first
+.info ok: double negation works
+.else
+.warning double negation fails
+.endif
 
-all:
-       @:;
+# Multiple targets can be combined using the && and || operators.
+.ifmake first && second
+.info ok: both mentioned
+.else
+.warning && does not work as expected
+.endif
+
+# Negation also works in complex conditions.
+.ifmake first && !unmentioned
+.info ok: only those mentioned
+.else
+.warning && with ! does not work as expected
+.endif
+
+first second unmentioned:
+       : $@



Home | Main Index | Thread Index | Old Index