xref: /freebsd/contrib/bmake/unit-tests/cmd-errors-jobs.mk (revision 759b177aecbfc49ebc900739954ac56b1aa5fc53)
1*759b177aSSimon J. Gerraty# $NetBSD: cmd-errors-jobs.mk,v 1.15 2025/03/29 19:08:52 rillig Exp $
206b9b3e0SSimon J. Gerraty#
3548bfc56SSimon J. Gerraty# Demonstrate how errors in expressions affect whether the commands
406b9b3e0SSimon J. Gerraty# are actually executed in jobs mode.
506b9b3e0SSimon J. Gerraty
66a7405f5SSimon J. GerratyRUN=	@ run() {					\
76a7405f5SSimon J. Gerraty		echo "begin $$*"			\
86a7405f5SSimon J. Gerraty		&& ${MAKE} -f ${MAKEFILE} -j1 "$$*"	\
96a7405f5SSimon J. Gerraty		&& echo "end $$* with status $$?"	\
106a7405f5SSimon J. Gerraty		|| echo "end $$* with status $$?"	\
116a7405f5SSimon J. Gerraty		&& echo;				\
126a7405f5SSimon J. Gerraty	} && run
1306b9b3e0SSimon J. Gerraty
146a7405f5SSimon J. Gerratyall:
156a7405f5SSimon J. Gerraty	${RUN} undefined-direct
166a7405f5SSimon J. Gerraty	${RUN} undefined-indirect
176a7405f5SSimon J. Gerraty	${RUN} parse-error-direct
186a7405f5SSimon J. Gerraty	${RUN} parse-error-indirect
196a7405f5SSimon J. Gerraty	${RUN} begin-direct
206a7405f5SSimon J. Gerraty	${RUN} begin-indirect
216a7405f5SSimon J. Gerraty	${RUN} end-direct
226a7405f5SSimon J. Gerraty	${RUN} end-indirect
236a7405f5SSimon J. Gerraty
2406b9b3e0SSimon J. Gerraty
25548bfc56SSimon J. Gerraty# Undefined variables in expressions are not an error.  They expand to empty
26548bfc56SSimon J. Gerraty# strings.
276a7405f5SSimon J. Gerraty# expect: : undefined-direct--eol
286a7405f5SSimon J. Gerraty# expect: end undefined-direct with status 0
296a7405f5SSimon J. Gerraty# expect: : undefined-direct--eol
306a7405f5SSimon J. Gerraty# expect: end undefined-indirect with status 0
316a7405f5SSimon J. Gerratyundefined-indirect: undefined-direct
326a7405f5SSimon J. Gerratyundefined-direct:
334fde40d9SSimon J. Gerraty	: $@-${UNDEFINED}-eol
3406b9b3e0SSimon J. Gerraty
3506b9b3e0SSimon J. Gerraty
366a7405f5SSimon J. Gerratyparse-error-indirect: parse-error-direct
376a7405f5SSimon J. Gerratyparse-error-direct: parse-error-unclosed-expression
386a7405f5SSimon J. Gerratyparse-error-direct: parse-error-unclosed-modifier
396a7405f5SSimon J. Gerratyparse-error-direct: parse-error-unknown-modifier
4006b9b3e0SSimon J. Gerraty
416a7405f5SSimon J. Gerratyparse-error-unclosed-expression:
426a7405f5SSimon J. Gerraty	: unexpected $@-${UNCLOSED
4306b9b3e0SSimon J. Gerraty
446a7405f5SSimon J. Gerratyparse-error-unclosed-modifier:
456a7405f5SSimon J. Gerraty	: unexpected $@-${UNCLOSED:
4606b9b3e0SSimon J. Gerraty
476a7405f5SSimon J. Gerratyparse-error-unknown-modifier:
486a7405f5SSimon J. Gerraty	: unexpected $@-${UNKNOWN:Z}-eol
496a7405f5SSimon J. Gerraty
50*759b177aSSimon J. Gerraty# expect-not-matches: ^: unexpected
516a7405f5SSimon J. Gerraty# expect: make: Unclosed variable "UNCLOSED"
52*759b177aSSimon J. Gerraty# expect: in command ": unexpected $@-${UNCLOSED"
536a7405f5SSimon J. Gerraty# expect: make: Unclosed expression, expecting '}'
54*759b177aSSimon J. Gerraty# expect: make: Unknown modifier ":Z"
556a7405f5SSimon J. Gerraty# expect: end parse-error-direct with status 2
566a7405f5SSimon J. Gerraty# expect: make: Unclosed variable "UNCLOSED"
576a7405f5SSimon J. Gerraty# expect: make: Unclosed expression, expecting '}'
58*759b177aSSimon J. Gerraty# expect: make: Unknown modifier ":Z"
596a7405f5SSimon J. Gerraty# expect: end parse-error-indirect with status 2
606a7405f5SSimon J. Gerraty
616a7405f5SSimon J. Gerraty
626a7405f5SSimon J. Gerraty.if make(begin-direct)
636a7405f5SSimon J. Gerratybegin-direct:
646a7405f5SSimon J. Gerraty.BEGIN:
656a7405f5SSimon J. Gerraty	(exit 13) # $@
666a7405f5SSimon J. Gerraty.endif
676a7405f5SSimon J. Gerraty# expect: begin begin-direct
686a7405f5SSimon J. Gerraty# expect: make: stopped making "begin-direct" in unit-tests
696a7405f5SSimon J. Gerraty# expect: end begin-direct with status 1
706a7405f5SSimon J. Gerraty
716a7405f5SSimon J. Gerraty
726a7405f5SSimon J. Gerraty.if make(begin-indirect)
736a7405f5SSimon J. Gerratybegin-indirect:
746a7405f5SSimon J. Gerraty.BEGIN: before-begin
756a7405f5SSimon J. Gerraty	: Making $@
766a7405f5SSimon J. Gerratybefore-begin:
776a7405f5SSimon J. Gerraty	(exit 13) # $@
786a7405f5SSimon J. Gerraty.endif
796a7405f5SSimon J. Gerraty# expect: begin begin-indirect
806a7405f5SSimon J. Gerraty# expect: *** Error code 13 (continuing)
816a7405f5SSimon J. Gerraty# expect: make: stopped making "begin-indirect" in unit-tests
826a7405f5SSimon J. Gerraty# expect: end begin-indirect with status 1
836a7405f5SSimon J. Gerraty
846a7405f5SSimon J. Gerraty
856a7405f5SSimon J. Gerraty.if make(end-direct)
866a7405f5SSimon J. Gerratyend-direct:
876a7405f5SSimon J. Gerraty.END:
886a7405f5SSimon J. Gerraty	(exit 13) # $@
896a7405f5SSimon J. Gerraty.endif
906a7405f5SSimon J. Gerraty# expect: begin end-direct
916a7405f5SSimon J. Gerraty# expect: *** Error code 13 (continuing)
926a7405f5SSimon J. Gerraty# expect: Stop.
936a7405f5SSimon J. Gerraty# expect: make: stopped making "end-direct" in unit-tests
946a7405f5SSimon J. Gerraty# expect: end end-direct with status 1
956a7405f5SSimon J. Gerraty
966a7405f5SSimon J. Gerraty.if make(end-indirect)
976a7405f5SSimon J. Gerratyend-indirect:
986a7405f5SSimon J. Gerraty.END: before-end
996a7405f5SSimon J. Gerraty	: Making $@
1006a7405f5SSimon J. Gerratybefore-end:
1016a7405f5SSimon J. Gerraty	(exit 13) # $@
1026a7405f5SSimon J. Gerraty.endif
1036a7405f5SSimon J. Gerraty# expect: begin end-indirect
1046a7405f5SSimon J. Gerraty# expect: *** Error code 13 (continuing)
1056a7405f5SSimon J. Gerraty# expect: make: stopped making "end-indirect" in unit-tests
1066a7405f5SSimon J. Gerraty# expect: end end-indirect with status 1
107