xref: /freebsd/contrib/bmake/unit-tests/deptgt-end-fail.mk (revision 954401e68e797868ab04a0147b94849feefbb199)
1*954401e6SSimon J. Gerraty# $NetBSD: deptgt-end-fail.mk,v 1.7 2022/05/07 08:01:20 rillig Exp $
206b9b3e0SSimon J. Gerraty#
306b9b3e0SSimon J. Gerraty# Tests for an errors in the main target, its dependencies,
406b9b3e0SSimon J. Gerraty# the .END node and its dependencies.
506b9b3e0SSimon J. Gerraty#
606b9b3e0SSimon J. Gerraty# Before 2020-11-25, an error in the .END target did not print the "Stop.",
706b9b3e0SSimon J. Gerraty# even though this was intended.  The cause for this was a missing condition
8*954401e6SSimon J. Gerraty# in Compat_MakeAll, in the code handling the .END node.
906b9b3e0SSimon J. Gerraty
1006b9b3e0SSimon J. Gerratytest: .PHONY
1106b9b3e0SSimon J. Gerraty
1206b9b3e0SSimon J. Gerraty# The default stop-on-error mode is not as interesting to test since it
1306b9b3e0SSimon J. Gerraty# stops right after the first error.
1406b9b3e0SSimon J. Gerraty.MAKEFLAGS: -k
1506b9b3e0SSimon J. Gerraty
1606b9b3e0SSimon J. Gerraty.for all in ok ERR
1706b9b3e0SSimon J. Gerraty.  for all-dep in ok ERR
1806b9b3e0SSimon J. Gerraty.    for end in ok ERR
1906b9b3e0SSimon J. Gerraty.      for end-dep in ok ERR
2006b9b3e0SSimon J. Gerraty.        for target in ${all}-${all-dep}-${end}-${end-dep}
2106b9b3e0SSimon J. Gerratytest: ${target}
2206b9b3e0SSimon J. Gerraty${target}: .PHONY .SILENT
2306b9b3e0SSimon J. Gerraty	echo Test case all=${all} all-dep=${all-dep} end=${end} end-dep=${end-dep}.
2406b9b3e0SSimon J. Gerraty	${MAKE} -r -f ${MAKEFILE} \
2506b9b3e0SSimon J. Gerraty		all=${all} all-dep=${all-dep} \
2606b9b3e0SSimon J. Gerraty		end=${end} end-dep=${end-dep} \
2706b9b3e0SSimon J. Gerraty		all; \
2806b9b3e0SSimon J. Gerraty	echo "exit status $$?"
2906b9b3e0SSimon J. Gerraty	echo
3006b9b3e0SSimon J. Gerraty	echo
3106b9b3e0SSimon J. Gerraty.        endfor
3206b9b3e0SSimon J. Gerraty.      endfor
3306b9b3e0SSimon J. Gerraty.    endfor
3406b9b3e0SSimon J. Gerraty.  endfor
3506b9b3e0SSimon J. Gerraty.endfor
3606b9b3e0SSimon J. Gerraty
3706b9b3e0SSimon J. Gerraty.if make(all)
3806b9b3e0SSimon J. Gerraty
3906b9b3e0SSimon J. Gerratyall all-dep end-dep: .PHONY
4006b9b3e0SSimon J. Gerraty
4106b9b3e0SSimon J. GerratyCMD.ok=		true
4206b9b3e0SSimon J. GerratyCMD.ERR=	false
4306b9b3e0SSimon J. Gerraty
4406b9b3e0SSimon J. Gerratyall: all-dep
4506b9b3e0SSimon J. Gerraty	: Making ${.TARGET} from ${.ALLSRC}.
4606b9b3e0SSimon J. Gerraty	@${CMD.${all}}
4706b9b3e0SSimon J. Gerraty
4806b9b3e0SSimon J. Gerratyall-dep:
4906b9b3e0SSimon J. Gerraty	: Making ${.TARGET} out of nothing.
5006b9b3e0SSimon J. Gerraty	@${CMD.${all-dep}}
5106b9b3e0SSimon J. Gerraty
5206b9b3e0SSimon J. Gerraty.END: end-dep
5306b9b3e0SSimon J. Gerraty	: Making ${.TARGET} from ${.ALLSRC}.
5406b9b3e0SSimon J. Gerraty	@${CMD.${end}}
5506b9b3e0SSimon J. Gerraty
5606b9b3e0SSimon J. Gerratyend-dep:
5706b9b3e0SSimon J. Gerraty	: Making ${.TARGET} out of nothing.
5806b9b3e0SSimon J. Gerraty	@${CMD.${end-dep}}
5906b9b3e0SSimon J. Gerraty
6006b9b3e0SSimon J. Gerraty.endif
6106b9b3e0SSimon J. Gerraty
6206b9b3e0SSimon J. Gerraty# Until 2020-12-07, several of the test cases printed "`all' not remade
6306b9b3e0SSimon J. Gerraty# because of errors.", followed by "exit status 0", which contradicted
6406b9b3e0SSimon J. Gerraty# each other.
6506b9b3e0SSimon J. Gerraty
6606b9b3e0SSimon J. Gerraty# Until 2020-12-07, '.END' was even made if 'all' failed, but if a dependency
6706b9b3e0SSimon J. Gerraty# of 'all' failed, it was skipped.  This inconsistency was not needed for
6806b9b3e0SSimon J. Gerraty# anything and thus has been dropped.  To run some commands on error, use the
6906b9b3e0SSimon J. Gerraty# .ERROR target instead, see deptgt-error.mk.
70