Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Add unit tests to check that exists(some/dir/) ...



details:   https://anonhg.NetBSD.org/src/rev/b0777cc5b057
branches:  trunk
changeset: 762930:b0777cc5b057
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sun Mar 06 00:02:14 2011 +0000

description:
Add unit tests to check that exists(some/dir/) works

Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""

diffstat:

 usr.bin/make/unit-tests/Makefile |   4 +++-
 usr.bin/make/unit-tests/cond1    |   7 ++++++-
 usr.bin/make/unit-tests/misc     |  16 ++++++++++++++++
 usr.bin/make/unit-tests/sysv     |  13 +++++++++++++
 usr.bin/make/unit-tests/test.exp |   2 ++
 usr.bin/make/var.c               |  18 +++++++++++-------
 6 files changed, 51 insertions(+), 9 deletions(-)

diffs (147 lines):

diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sat Mar 05 23:57:05 2011 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Mar 06 00:02:14 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.30 2010/12/10 00:37:23 sjg Exp $
+# $NetBSD: Makefile,v 1.31 2011/03/06 00:02:14 sjg Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -27,6 +27,7 @@
        doterror \
        dotwait \
        forsubst \
+       misc \
        moderrs \
        modmatch \
        modmisc \
@@ -35,6 +36,7 @@
        modword \
        posix \
        qequals \
+       sysv \
        ternary \
        unexport \
        unexport-env \
diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/unit-tests/cond1
--- a/usr.bin/make/unit-tests/cond1     Sat Mar 05 23:57:05 2011 +0000
+++ b/usr.bin/make/unit-tests/cond1     Sun Mar 06 00:02:14 2011 +0000
@@ -1,4 +1,4 @@
-# $Id: cond1,v 1.4 2008/10/29 15:37:08 sjg Exp $
+# $Id: cond1,v 1.5 2011/03/06 00:02:14 sjg Exp $
 
 # hard code these!
 TEST_UNAME_S= NetBSD
@@ -95,6 +95,11 @@
 C=dim
 .endif
 
+.if defined(nosuch) && ${nosuch:Mx} != ""
+# this should not happen
+.info nosuch is x
+.endif
+
 all:
        @echo "$n is $X prime"
        @echo "A='$A' B='$B' C='$C' o='$o,${o2}'"
diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/unit-tests/misc
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/misc      Sun Mar 06 00:02:14 2011 +0000
@@ -0,0 +1,16 @@
+# $Id: misc,v 1.1 2011/03/06 00:02:14 sjg Exp $
+
+.if !exists(${.CURDIR}/)
+.warning ${.CURDIR}/ doesn't exist ?
+.endif
+
+.if !exists(${.CURDIR}/.)
+.warning ${.CURDIR}/. doesn't exist ?
+.endif
+
+.if !exists(${.CURDIR}/..)
+.warning ${.CURDIR}/.. doesn't exist ?
+.endif
+
+all:
+       @: all is well
diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/unit-tests/sysv
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/sysv      Sun Mar 06 00:02:14 2011 +0000
@@ -0,0 +1,13 @@
+# $Id: sysv,v 1.1 2011/03/06 00:02:14 sjg Exp $
+
+FOO ?=
+FOOBAR = $(FOO:=bar)
+
+_this := ${.PARSEDIR}/${.PARSEFILE}
+
+# we expect nothing when FOO is empty
+all:
+       @echo FOOBAR = $(FOOBAR)
+.if empty(FOO)
+       @FOO="foo fu" ${.MAKE} -f ${_this}
+.endif
diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp  Sat Mar 05 23:57:05 2011 +0000
+++ b/usr.bin/make/unit-tests/test.exp  Sun Mar 06 00:02:14 2011 +0000
@@ -306,6 +306,8 @@
 *** Error code 1 (continuing)
 `all' not remade because of errors.
 V.i386 ?= OK
+FOOBAR =
+FOOBAR = foobar fubar
 The answer is unknown
 The answer is unknown
 The answer is empty
diff -r 77aad1fac635 -r b0777cc5b057 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Mar 05 23:57:05 2011 +0000
+++ b/usr.bin/make/var.c        Sun Mar 06 00:02:14 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $       */
+/*     $NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.161 2010/12/02 16:46:22 christos Exp $");
+__RCSID("$NetBSD: var.c,v 1.162 2011/03/06 00:02:15 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3346,9 +3346,13 @@
                 */
                termc = *--cp;
                delim = '\0';
-               newStr = VarModify(ctxt, &parsestate, nstr,
-                                  VarSYSVMatch,
-                                  &pattern);
+               if (pattern.leftLen == 0 && *nstr == '\0') {
+                   newStr = nstr;      /* special case */
+               } else {
+                   newStr = VarModify(ctxt, &parsestate, nstr,
+                                      VarSYSVMatch,
+                                      &pattern);
+               }
                free(UNCONST(pattern.lhs));
                free(UNCONST(pattern.rhs));
            } else
@@ -3746,7 +3750,7 @@
                nstr = bmake_strndup(start, *lengthPtr);
                *freePtr = nstr;
            } else {
-               nstr = var_Error;
+               nstr = errnum ? var_Error : varNoError;
            }
        }
        if (nstr != Buf_GetAll(&v->val, NULL))



Home | Main Index | Thread Index | Old Index