xref: /freebsd-src/contrib/bmake/unit-tests/compat-error.mk (revision 954401e68e797868ab04a0147b94849feefbb199)
1*954401e6SSimon J. Gerraty# $NetBSD: compat-error.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
206b9b3e0SSimon J. Gerraty#
306b9b3e0SSimon J. Gerraty# Test detailed error handling in compat mode.
406b9b3e0SSimon J. Gerraty#
5*954401e6SSimon J. Gerraty# Make several targets that alternately succeed and fail.
606b9b3e0SSimon J. Gerraty#
7*954401e6SSimon J. Gerraty# The first failing top-level target is recorded in '.ERROR_TARGET'.  While
8*954401e6SSimon J. Gerraty# this information may give a hint as to which target failed, it would be more
9*954401e6SSimon J. Gerraty# useful at that point to know the actual target that failed, or the complete
10*954401e6SSimon J. Gerraty# chain from root cause to top-level target.
11*954401e6SSimon J. Gerraty#
12*954401e6SSimon J. Gerraty# Historic bugs
13*954401e6SSimon J. Gerraty#	Before compat.c 1.215 from 2020-12-13, '.ERROR_TARGET' was 'success3',
14*954401e6SSimon J. Gerraty#	which was obviously wrong.
15*954401e6SSimon J. Gerraty#
16*954401e6SSimon J. Gerraty# Bugs
17*954401e6SSimon J. Gerraty#	As of 2020-12-13, '.ERROR_CMD' is empty, which does not provide any
18*954401e6SSimon J. Gerraty#	insight into the command that actually failed.
1906b9b3e0SSimon J. Gerraty#
2006b9b3e0SSimon J. Gerraty# See also:
21*954401e6SSimon J. Gerraty#	Compat_MakeAll
2206b9b3e0SSimon J. Gerraty#
2306b9b3e0SSimon J. Gerraty#	The commit that added the NULL command to gn->commands:
2406b9b3e0SSimon J. Gerraty#		CVS: 1994.06.06.22.45.??
2506b9b3e0SSimon J. Gerraty#		Git: 26a8972fd7f982502c5fbfdabd34578b99d77ca5
2606b9b3e0SSimon J. Gerraty#		1994: Lst_Replace (cmdNode, (ClientData) NULL);
2706b9b3e0SSimon J. Gerraty#		2020: LstNode_SetNull(cmdNode);
2806b9b3e0SSimon J. Gerraty#
2906b9b3e0SSimon J. Gerraty#	The commit that skipped NULL commands for .ERROR_CMD:
30*954401e6SSimon J. Gerraty#		CVS: 2016.08.11.19.53.17
3106b9b3e0SSimon J. Gerraty#		Git: 58b23478b7353d46457089e726b07a49197388e4
3206b9b3e0SSimon J. Gerraty
33*954401e6SSimon J. Gerraty.MAKEFLAGS: -k success1 fail1 success2 fail2 success3
3406b9b3e0SSimon J. Gerraty
3506b9b3e0SSimon J. Gerratysuccess1 success2 success3:
3606b9b3e0SSimon J. Gerraty	: Making ${.TARGET} out of nothing.
3706b9b3e0SSimon J. Gerraty
3806b9b3e0SSimon J. Gerratyfail1 fail2:
3906b9b3e0SSimon J. Gerraty	: Making ${.TARGET} out of nothing.
4006b9b3e0SSimon J. Gerraty	false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
4106b9b3e0SSimon J. Gerraty
4206b9b3e0SSimon J. Gerraty.ERROR:
4306b9b3e0SSimon J. Gerraty	@echo ${.TARGET} target: '<'${.ERROR_TARGET:Q}'>'
4406b9b3e0SSimon J. Gerraty	@echo ${.TARGET} command: '<'${.ERROR_CMD:Q}'>'
45