Module Name: src
Committed By: sjg
Date: Thu Apr 8 17:41:29 UTC 2010
Modified Files:
src/usr.bin/make: main.c parse.c
src/usr.bin/make/unit-tests: Makefile test.exp
Added Files:
src/usr.bin/make/unit-tests: doterror error
Log Message:
Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target.
Add unit-tests for .info - .error, and .ERROR.
To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/main.c
cvs rdiff -u -r1.161 -r1.162 src/usr.bin/make/parse.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/doterror \
src/usr.bin/make/unit-tests/error
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/test.exp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.176 src/usr.bin/make/main.c:1.177
--- src/usr.bin/make/main.c:1.176 Wed Apr 7 00:11:27 2010
+++ src/usr.bin/make/main.c Thu Apr 8 17:41:29 2010
@@ -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.
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.161 src/usr.bin/make/parse.c:1.162
--- src/usr.bin/make/parse.c:1.161 Wed Apr 7 00:11:27 2010
+++ src/usr.bin/make/parse.c Thu Apr 8 17:41:29 2010
@@ -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
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.25 src/usr.bin/make/unit-tests/Makefile:1.26
--- src/usr.bin/make/unit-tests/Makefile:1.25 Thu Nov 19 00:30:25 2009
+++ src/usr.bin/make/unit-tests/Makefile Thu Apr 8 17:41:29 2010
@@ -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
Index: src/usr.bin/make/unit-tests/test.exp
diff -u src/usr.bin/make/unit-tests/test.exp:1.30 src/usr.bin/make/unit-tests/test.exp:1.31
--- src/usr.bin/make/unit-tests/test.exp:1.30 Thu Nov 19 00:30:25 2009
+++ src/usr.bin/make/unit-tests/test.exp Thu Apr 8 17:41:29 2010
@@ -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)
Added files:
Index: src/usr.bin/make/unit-tests/doterror
diff -u /dev/null src/usr.bin/make/unit-tests/doterror:1.1
--- /dev/null Thu Apr 8 17:41:30 2010
+++ src/usr.bin/make/unit-tests/doterror Thu Apr 8 17:41:29 2010
@@ -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
+
Index: src/usr.bin/make/unit-tests/error
diff -u /dev/null src/usr.bin/make/unit-tests/error:1.1
--- /dev/null Thu Apr 8 17:41:30 2010
+++ src/usr.bin/make/unit-tests/error Thu Apr 8 17:41:29 2010
@@ -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
+