Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make Process .ERROR the same as .BEGIN, .END etc



details:   https://anonhg.NetBSD.org/src/rev/6be32291805f
branches:  trunk
changeset: 753741:6be32291805f
user:      sjg <sjg%NetBSD.org@localhost>
date:      Thu Apr 08 17:41:29 2010 +0000

description:
Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.

diffstat:

 usr.bin/make/main.c              |  10 ++++++----
 usr.bin/make/parse.c             |  11 ++++++++---
 usr.bin/make/unit-tests/Makefile |   8 ++++++--
 usr.bin/make/unit-tests/doterror |  20 ++++++++++++++++++++
 usr.bin/make/unit-tests/error    |   6 ++++++
 usr.bin/make/unit-tests/test.exp |  13 +++++++++++++
 6 files changed, 59 insertions(+), 9 deletions(-)

diffs (214 lines):

diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/main.c
--- a/usr.bin/make/main.c       Thu Apr 08 17:32:30 2010 +0000
+++ b/usr.bin/make/main.c       Thu Apr 08 17:41:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.176 2010/04/07 00:11:27 sjg Exp $   */
+/*     $NetBSD: main.c,v 1.177 2010/04/08 17:41:29 sjg Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.176 2010/04/07 00:11:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.177 2010/04/08 17:41:29 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.176 2010/04/07 00:11:27 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.177 2010/04/08 17:41:29 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1876,7 +1876,7 @@
 void
 PrintOnError(GNode *gn, const char *s)
 {
-    GNode *en;
+    static GNode *en = NULL;
     char tmp[64];
     char *cp;
 
@@ -1885,6 +1885,8 @@
        
     printf("\n%s: stopped in %s\n", progname, curdir);
 
+    if (en)
+       return;                         /* we've been here! */
     if (gn) {
        /*
         * We can print this even if there is no .ERROR target.
diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Thu Apr 08 17:32:30 2010 +0000
+++ b/usr.bin/make/parse.c      Thu Apr 08 17:41:29 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.161 2010/04/07 00:11:27 sjg Exp $  */
+/*     $NetBSD: parse.c,v 1.162 2010/04/08 17:41:29 sjg Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.161 2010/04/07 00:11:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.162 2010/04/08 17:41:29 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.161 2010/04/07 00:11:27 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.162 2010/04/08 17:41:29 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -191,6 +191,7 @@
     Begin,         /* .BEGIN */
     Default,       /* .DEFAULT */
     End,           /* .END */
+    dotError,      /* .ERROR */
     Ignore,        /* .IGNORE */
     Includes,      /* .INCLUDES */
     Interrupt,     /* .INTERRUPT */
@@ -245,6 +246,7 @@
 { ".BEGIN",      Begin,        0 },
 { ".DEFAULT",    Default,      0 },
 { ".END",        End,          0 },
+{ ".ERROR",      dotError,     0 },
 { ".EXEC",       Attribute,    OP_EXEC },
 { ".IGNORE",     Ignore,       OP_IGNORE },
 { ".INCLUDES",   Includes,     0 },
@@ -1017,6 +1019,7 @@
                 *      .NOPATH         Don't search for file in the path
                 *      .BEGIN
                 *      .END
+                *      .ERROR
                 *      .INTERRUPT      Are not to be considered the
                 *                      main target.
                 *      .NOTPARALLEL    Make only one target at a time.
@@ -1037,6 +1040,7 @@
                        break;
                    case Begin:
                    case End:
+                   case dotError:
                    case Interrupt:
                        gn = Targ_FindNode(line, TARG_CREATE);
                        gn->type |= OP_NOTMAIN|OP_SPECIAL;
@@ -1166,6 +1170,7 @@
            case Default:
            case Begin:
            case End:
+           case dotError:
            case Interrupt:
                /*
                 * These four create nodes on which to hang commands, so
diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Thu Apr 08 17:32:30 2010 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Thu Apr 08 17:41:29 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.25 2009/11/19 00:30:25 sjg Exp $
+# $NetBSD: Makefile,v 1.26 2010/04/08 17:41:29 sjg Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -21,8 +21,10 @@
 SUBFILES= \
        comment \
        cond1 \
+       error \
        export \
        export-all \
+       doterror \
        dotwait \
        forsubst \
        moderrs \
@@ -40,11 +42,13 @@
 
 all: ${SUBFILES}
 
+flags.doterror=
+
 # the tests are actually done with sub-makes.
 .PHONY: ${SUBFILES}
 .PRECIOUS: ${SUBFILES}
 ${SUBFILES}:
-       -@${.MAKE} -k -f ${UNIT_TESTS}/$@
+       -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
 
 clean:
        rm -f *.out *.fail *.core
diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/unit-tests/doterror
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/doterror  Thu Apr 08 17:41:29 2010 +0000
@@ -0,0 +1,20 @@
+# $Id: doterror,v 1.1 2010/04/08 17:41:29 sjg Exp $
+
+
+.BEGIN:
+       @echo At first, I am
+
+.END:
+       @echo not reached
+
+.ERROR:
+       @echo "$@: Looks like '${.ERROR_TARGET}' is upset."
+
+all:   happy sad
+
+happy:
+       @echo $@
+
+sad:
+       @echo and now: $@; exit 1
+
diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/unit-tests/error
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/error     Thu Apr 08 17:41:29 2010 +0000
@@ -0,0 +1,6 @@
+# $Id: error,v 1.1 2010/04/08 17:41:29 sjg Exp $
+
+.info just FYI
+.warning this could be serious
+.error this is fatal
+
diff -r 416a79e04f1c -r 6be32291805f usr.bin/make/unit-tests/test.exp
--- a/usr.bin/make/unit-tests/test.exp  Thu Apr 08 17:32:30 2010 +0000
+++ b/usr.bin/make/unit-tests/test.exp  Thu Apr 08 17:41:29 2010 +0000
@@ -24,6 +24,9 @@
 make: Bad conditional expression `"0" > 0' in "0" > 0?OK:No
 
 OK
+make: "error" line 3: just FYI
+make: "error" line 4: warning: this could be serious
+make: "error" line 5: this is fatal
 UT_DOLLAR=This is $UT_FU
 UT_FOO=foobar is fubar
 UT_FU=fubar
@@ -38,6 +41,14 @@
 UT_OK=good
 UT_TEST=export-all
 UT_ZOO=hoopie
+At first, I am
+happy
+and now: sad
+.ERROR: Looks like 'sad' is upset.
+*** Error code 1
+
+Stop.
+make: stopped in unit-tests
 simple.1
 simple.1
 simple.2
@@ -314,3 +325,5 @@
 five v=is x k=is x
 six v=is y k=is y
 show-v v=override k=override
+*** Error code 1 (ignored)
+*** Error code 1 (ignored)



Home | Main Index | Thread Index | Old Index