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 .ifndef and ....



details:   https://anonhg.NetBSD.org/src/rev/01bd42d30741
branches:  trunk
changeset: 955606:01bd42d30741
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 04 22:41:18 2020 +0000

description:
make(1): add tests for .ifndef and .ifnmake

diffstat:

 usr.bin/make/unit-tests/directive-ifndef.exp  |   1 +
 usr.bin/make/unit-tests/directive-ifndef.mk   |  22 +++++++++++++++++++---
 usr.bin/make/unit-tests/directive-ifnmake.exp |   2 ++
 usr.bin/make/unit-tests/directive-ifnmake.mk  |  22 ++++++++++++++++++----
 4 files changed, 40 insertions(+), 7 deletions(-)

diffs (74 lines):

diff -r a0d96ef9b2e8 -r 01bd42d30741 usr.bin/make/unit-tests/directive-ifndef.exp
--- a/usr.bin/make/unit-tests/directive-ifndef.exp      Sun Oct 04 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifndef.exp      Sun Oct 04 22:41:18 2020 +0000
@@ -1,1 +1,2 @@
+make: "directive-ifndef.mk" line 10: guarded section
 exit status 0
diff -r a0d96ef9b2e8 -r 01bd42d30741 usr.bin/make/unit-tests/directive-ifndef.mk
--- a/usr.bin/make/unit-tests/directive-ifndef.mk       Sun Oct 04 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifndef.mk       Sun Oct 04 22:41:18 2020 +0000
@@ -1,8 +1,24 @@
-# $NetBSD: directive-ifndef.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-ifndef.mk,v 1.3 2020/10/04 22:41:18 rillig Exp $
 #
-# Tests for the .ifndef directive.
+# Tests for the .ifndef directive, which can be used for multiple-inclusion
+# guards.  In contrast to C, where #ifndef and #define nicely line up the
+# macro name, there is no such syntax in make.  Therefore, it is more
+# common to use .if !defined(GUARD) instead.
+
+.ifndef GUARD
+GUARD= # defined
+.info guarded section
+.endif
 
-# TODO: Implementation
+.ifndef GUARD
+GUARD= # defined
+.info guarded section
+.endif
+
+.if !defined(GUARD)
+GUARD= # defined
+.info guarded section
+.endif
 
 all:
        @:;
diff -r a0d96ef9b2e8 -r 01bd42d30741 usr.bin/make/unit-tests/directive-ifnmake.exp
--- a/usr.bin/make/unit-tests/directive-ifnmake.exp     Sun Oct 04 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifnmake.exp     Sun Oct 04 22:41:18 2020 +0000
@@ -1,1 +1,3 @@
+Don't forget to run the tests (1)
+Running the tests
 exit status 0
diff -r a0d96ef9b2e8 -r 01bd42d30741 usr.bin/make/unit-tests/directive-ifnmake.mk
--- a/usr.bin/make/unit-tests/directive-ifnmake.mk      Sun Oct 04 21:53:28 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifnmake.mk      Sun Oct 04 22:41:18 2020 +0000
@@ -1,8 +1,22 @@
-# $NetBSD: directive-ifnmake.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: directive-ifnmake.mk,v 1.3 2020/10/04 22:41:18 rillig Exp $
 #
-# Tests for the .ifnmake directive.
-
-# TODO: Implementation
+# Tests for the .ifnmake directive, which evaluates to true if its argument
+# is _not_ listed in the command-line targets to be created.
 
 all:
        @:;
+
+.ifnmake(test)
+.BEGIN:
+       @echo "Don't forget to run the tests (1)"
+.endif
+
+.MAKEFLAGS: test
+
+.ifnmake(test)
+.BEGIN:
+       @echo "Don't forget to run the tests (2)"
+.endif
+
+test:
+       @echo "Running the tests"



Home | Main Index | Thread Index | Old Index