xref: /freebsd/contrib/bmake/unit-tests/cmd-errors.mk (revision 226192822cddc30cacecd55bccb48f39c653058c)
1# $NetBSD: cmd-errors.mk,v 1.9 2024/07/09 19:43:01 rillig Exp $
2#
3# Demonstrate how errors in expressions affect whether the commands
4# are actually executed in compat mode.
5
6all: undefined unclosed-expression unclosed-modifier unknown-modifier end
7
8# Undefined variables in expressions are not an error.  They expand to empty
9# strings.
10undefined:
11# expect: : undefined--eol
12	: $@-${UNDEFINED}-eol
13
14unclosed-expression:
15# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
16# XXX: This command is executed even though it contains parse errors.
17# expect: : unclosed-expression-
18	: $@-${UNCLOSED
19
20unclosed-modifier:
21# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
22# XXX: This command is executed even though it contains parse errors.
23# expect: : unclosed-modifier-
24	: $@-${UNCLOSED:
25
26unknown-modifier:
27# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
28# XXX: This command is executed even though it contains parse errors.
29# expect: : unknown-modifier--eol
30	: $@-${UNKNOWN:Z}-eol
31
32end:
33# expect: : end-eol
34	: $@-eol
35
36# expect: exit status 2
37