blob: 471f2cbb327ca80664204fc70d41392ac58cb1bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# $NetBSD: cmd-errors-jobs.mk,v 1.13 2024/08/29 20:20:35 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed in jobs mode.
RUN= @ run() { \
echo "begin $$*" \
&& ${MAKE} -f ${MAKEFILE} -j1 "$$*" \
&& echo "end $$* with status $$?" \
|| echo "end $$* with status $$?" \
&& echo; \
} && run
all:
${RUN} undefined-direct
${RUN} undefined-indirect
${RUN} parse-error-direct
${RUN} parse-error-indirect
${RUN} begin-direct
${RUN} begin-indirect
${RUN} end-direct
${RUN} end-indirect
# Undefined variables in expressions are not an error. They expand to empty
# strings.
# expect: : undefined-direct--eol
# expect: end undefined-direct with status 0
# expect: : undefined-direct--eol
# expect: end undefined-indirect with status 0
undefined-indirect: undefined-direct
undefined-direct:
: $@-${UNDEFINED}-eol
parse-error-indirect: parse-error-direct
parse-error-direct: parse-error-unclosed-expression
parse-error-direct: parse-error-unclosed-modifier
parse-error-direct: parse-error-unknown-modifier
parse-error-unclosed-expression:
: unexpected $@-${UNCLOSED
parse-error-unclosed-modifier:
: unexpected $@-${UNCLOSED:
parse-error-unknown-modifier:
: unexpected $@-${UNKNOWN:Z}-eol
# expect-not: : unexpected
# expect: make: Unclosed variable "UNCLOSED"
# expect: make: Unclosed expression, expecting '}'
# expect: make: Unknown modifier "Z"
# expect: end parse-error-direct with status 2
# expect: make: Unclosed variable "UNCLOSED"
# expect: make: Unclosed expression, expecting '}'
# expect: make: Unknown modifier "Z"
# expect: end parse-error-indirect with status 2
.if make(begin-direct)
begin-direct:
.BEGIN:
(exit 13) # $@
.endif
# expect: begin begin-direct
# expect: make: stopped making "begin-direct" in unit-tests
# expect: end begin-direct with status 1
.if make(begin-indirect)
begin-indirect:
.BEGIN: before-begin
: Making $@
before-begin:
(exit 13) # $@
.endif
# expect: begin begin-indirect
# expect: *** Error code 13 (continuing)
# expect: make: stopped making "begin-indirect" in unit-tests
# expect: end begin-indirect with status 1
.if make(end-direct)
end-direct:
.END:
(exit 13) # $@
.endif
# expect: begin end-direct
# expect: *** Error code 13 (continuing)
# expect: Stop.
# expect: make: stopped making "end-direct" in unit-tests
# expect: end end-direct with status 1
.if make(end-indirect)
end-indirect:
.END: before-end
: Making $@
before-end:
(exit 13) # $@
.endif
# expect: begin end-indirect
# expect: *** Error code 13 (continuing)
# expect: make: stopped making "end-indirect" in unit-tests
# expect: end end-indirect with status 1
|