Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): add test to cover the If_Eval call in ...



details:   https://anonhg.NetBSD.org/src/rev/d9c697022638
branches:  trunk
changeset: 956942:d9c697022638
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Nov 11 07:13:42 2020 +0000

description:
make(1): add test to cover the If_Eval call in EvalNotEmpty

diffstat:

 usr.bin/make/cond.c                          |   8 ++++----
 usr.bin/make/unit-tests/directive-ifmake.exp |  13 +++++++------
 usr.bin/make/unit-tests/directive-ifmake.mk  |  13 ++++++++++++-
 3 files changed, 23 insertions(+), 11 deletions(-)

diffs (82 lines):

diff -r bbfa04321cbe -r d9c697022638 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Wed Nov 11 07:10:19 2020 +0000
+++ b/usr.bin/make/cond.c       Wed Nov 11 07:13:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.203 2020/11/10 22:25:38 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.204 2020/11/11 07:13:42 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -93,7 +93,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.203 2020/11/10 22:25:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.204 2020/11/11 07:13:42 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -536,11 +536,11 @@
     if (TryParseNumber(value, &num))
        return num != 0.0;
 
-    /* For .if ${...}, check for non-empty string (defProc is ifdef). */
+    /* For .if ${...}, check for non-empty string. */
     if (par->if_info->form[0] == '\0')
        return value[0] != '\0';
 
-    /* Otherwise action default test ... */
+    /* For the other variants of .ifxxx ${...}, use its default function. */
     return If_Eval(par->if_info, value, strlen(value));
 }
 
diff -r bbfa04321cbe -r d9c697022638 usr.bin/make/unit-tests/directive-ifmake.exp
--- a/usr.bin/make/unit-tests/directive-ifmake.exp      Wed Nov 11 07:10:19 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifmake.exp      Wed Nov 11 07:13:42 2020 +0000
@@ -1,9 +1,10 @@
-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
-make: "directive-ifmake.mk" line 49: Targets can even be added at parse time.
+make: "directive-ifmake.mk" line 10: ok: positive condition works
+make: "directive-ifmake.mk" line 21: ok: negation works
+make: "directive-ifmake.mk" line 27: ok: double negation works
+make: "directive-ifmake.mk" line 34: ok: both mentioned
+make: "directive-ifmake.mk" line 41: ok: only those mentioned
+make: "directive-ifmake.mk" line 51: Targets can even be added at parse time.
+make: "directive-ifmake.mk" line 69: ok
 : first
 : second
 : late-target
diff -r bbfa04321cbe -r d9c697022638 usr.bin/make/unit-tests/directive-ifmake.mk
--- a/usr.bin/make/unit-tests/directive-ifmake.mk       Wed Nov 11 07:10:19 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-ifmake.mk       Wed Nov 11 07:13:42 2020 +0000
@@ -1,8 +1,10 @@
-# $NetBSD: directive-ifmake.mk,v 1.6 2020/11/08 22:45:51 rillig Exp $
+# $NetBSD: directive-ifmake.mk,v 1.7 2020/11/11 07:13:42 rillig Exp $
 #
 # Tests for the .ifmake directive, which provides a shortcut for asking
 # whether a certain target is requested to be made from the command line.
 
+# The targets 'first' and 'second' are passed in on the command line.
+
 # This is the most basic form.
 .ifmake first
 .  info ok: positive condition works
@@ -61,5 +63,14 @@
 .  error
 .endif
 
+# A condition that consists of a variable expression only (without any
+# comparison operator) can be used with .if and the other .ifxxx directives.
+.ifmake ${:Ufirst}
+.  info ok
+.else
+.  error
+.endif
+
+
 first second unmentioned late-target:
        : $@



Home | Main Index | Thread Index | Old Index