Process .ERROR the same as .BEGIN, .END etc
so that it cannot be the default target. Add unit-tests for .info - .error, and .ERROR.
This commit is contained in:
parent
5a858cc492
commit
dc03377f35
|
@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
|
|||
#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 @@ PrintAddr(void *a, void *b)
|
|||
void
|
||||
PrintOnError(GNode *gn, const char *s)
|
||||
{
|
||||
GNode *en;
|
||||
static GNode *en = NULL;
|
||||
char tmp[64];
|
||||
char *cp;
|
||||
|
||||
|
@ -1885,6 +1885,8 @@ PrintOnError(GNode *gn, const char *s)
|
|||
|
||||
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.
|
||||
|
|
|
@ -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 @@ typedef enum {
|
|||
Begin, /* .BEGIN */
|
||||
Default, /* .DEFAULT */
|
||||
End, /* .END */
|
||||
dotError, /* .ERROR */
|
||||
Ignore, /* .IGNORE */
|
||||
Includes, /* .INCLUDES */
|
||||
Interrupt, /* .INTERRUPT */
|
||||
|
@ -245,6 +246,7 @@ static struct {
|
|||
{ ".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 @@ ParseDoDependency(char *line)
|
|||
* .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 @@ ParseDoDependency(char *line)
|
|||
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 @@ ParseDoDependency(char *line)
|
|||
case Default:
|
||||
case Begin:
|
||||
case End:
|
||||
case dotError:
|
||||
case Interrupt:
|
||||
/*
|
||||
* These four create nodes on which to hang commands, so
|
||||
|
|
|
@ -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 @@ UNIT_TESTS:= ${.PARSEDIR}
|
|||
SUBFILES= \
|
||||
comment \
|
||||
cond1 \
|
||||
error \
|
||||
export \
|
||||
export-all \
|
||||
doterror \
|
||||
dotwait \
|
||||
forsubst \
|
||||
moderrs \
|
||||
|
@ -40,11 +42,13 @@ SUBFILES= \
|
|||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -24,6 +24,9 @@ make: warning: String comparison operator should be either == or !=
|
|||
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_NO=all
|
|||
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 FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v>
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue