xref: /freebsd/contrib/bmake/unit-tests/compat-error.mk (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1# $NetBSD: compat-error.mk,v 1.5 2022/05/08 06:51:27 rillig Exp $
2#
3# Test detailed error handling in compat mode.
4#
5# Make several targets that alternately succeed and fail.
6#
7# The first failing top-level target is recorded in '.ERROR_TARGET'.  While
8# this information may give a hint as to which target failed, it would be more
9# useful at that point to know the actual target that failed, or the complete
10# chain from root cause to top-level target.
11#
12# Historic bugs
13#	Before compat.c 1.215 from 2020-12-13, '.ERROR_TARGET' was 'success3',
14#	which was obviously wrong.
15#
16# Bugs
17#	As of 2020-12-13, '.ERROR_CMD' is empty, which does not provide any
18#	insight into the command that actually failed.
19#
20# See also:
21#	Compat_MakeAll
22#
23#	The commit that added the NULL command to gn->commands:
24#		CVS: 1994.06.06.22.45.??
25#		Git: 26a8972fd7f982502c5fbfdabd34578b99d77ca5
26#		1994: Lst_Replace (cmdNode, (ClientData) NULL);
27#		2020: LstNode_SetNull(cmdNode);
28#
29#	The commit that skipped NULL commands for .ERROR_CMD:
30#		CVS: 2016.08.11.19.53.17
31#		Git: 58b23478b7353d46457089e726b07a49197388e4
32
33.MAKEFLAGS: -k success1 fail1 success2 fail2 success3
34
35success1 success2 success3:
36	: Making ${.TARGET} out of nothing.
37
38fail1 fail2:
39	: Making ${.TARGET} out of nothing.
40	false '${.TARGET}' '$${.TARGET}' '$$$${.TARGET}'
41
42.ERROR:
43	@echo ${.TARGET} target: '<'${.ERROR_TARGET:Q}'>'
44	@echo ${.TARGET} command: '<'${.ERROR_CMD:Q}'>'
45