xref: /freebsd/contrib/bmake/unit-tests/posix-execution.mk (revision 759b177aecbfc49ebc900739954ac56b1aa5fc53)
1*759b177aSSimon J. Gerraty# $NetBSD: posix-execution.mk,v 1.1 2025/04/13 09:29:32 rillig Exp $
2*759b177aSSimon J. Gerraty#
3*759b177aSSimon J. Gerraty# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_03
4*759b177aSSimon J. Gerraty#
5*759b177aSSimon J. Gerraty
6*759b177aSSimon J. Gerraty.POSIX:
7*759b177aSSimon J. Gerraty
8*759b177aSSimon J. Gerraty
9*759b177aSSimon J. Gerraty# The target consists of two commands, which are executed separately.
10*759b177aSSimon J. Gerraty# The second command thus does not see the shell variable from the first
11*759b177aSSimon J. Gerraty# command.
12*759b177aSSimon J. Gerraty# expect: one-at-a-time: shell_variable is 'second'
13*759b177aSSimon J. Gerratyall: one-at-a-time
14*759b177aSSimon J. Gerratyone-at-a-time:
15*759b177aSSimon J. Gerraty	@shell_variable=first
16*759b177aSSimon J. Gerraty	@echo "$@: shell_variable is '$${shell_variable:-second}'"
17*759b177aSSimon J. Gerraty
18*759b177aSSimon J. Gerraty
19*759b177aSSimon J. Gerraty# expect: echo "prefixes: ignore errors"; exit 13
20*759b177aSSimon J. Gerraty# expect: prefixes: ignore errors
21*759b177aSSimon J. Gerraty# expect-not: echo "prefixes: no echo"
22*759b177aSSimon J. Gerraty# expect: prefixes: no echo
23*759b177aSSimon J. Gerraty# expect: prefixes: always, no echo
24*759b177aSSimon J. Gerratyall: prefixes
25*759b177aSSimon J. Gerratyprefixes:
26*759b177aSSimon J. Gerraty	-echo "$@: ignore errors"; exit 13
27*759b177aSSimon J. Gerraty	@echo "$@: no echo"
28*759b177aSSimon J. Gerraty	+@echo "$@: always, no echo"
29*759b177aSSimon J. Gerraty
30*759b177aSSimon J. Gerraty
31*759b177aSSimon J. Gerraty# Deviation from POSIX: The shell "-e" option is not in effect.
32*759b177aSSimon J. Gerraty# expect: shell-e-option: before
33*759b177aSSimon J. Gerraty# expect: shell-e-option: after
34*759b177aSSimon J. Gerratyall: shell-e-option
35*759b177aSSimon J. Gerratyshell-e-option:
36*759b177aSSimon J. Gerraty	@echo '$@: before'; false; echo '$@: after'
37*759b177aSSimon J. Gerraty
38*759b177aSSimon J. Gerraty
39*759b177aSSimon J. Gerraty# expect-not-matches: ^do%-prefix%-plus: a regular command
40*759b177aSSimon J. Gerraty# expect: do-prefix-plus: prefixed by plus
41*759b177aSSimon J. Gerraty# expect: do-prefix-plus: prefixed by plus
42*759b177aSSimon J. Gerratyall: prefix-plus
43*759b177aSSimon J. Gerratyprefix-plus:
44*759b177aSSimon J. Gerraty	@${MAKE} -f ${MAKEFILE} -n do-prefix-plus
45*759b177aSSimon J. Gerraty	@${MAKE} -f ${MAKEFILE} -n -j1 do-prefix-plus
46*759b177aSSimon J. Gerratydo-prefix-plus:
47*759b177aSSimon J. Gerraty	@echo '$@: a regular command'
48*759b177aSSimon J. Gerraty	@+echo '$@: prefixed by plus'
49*759b177aSSimon J. Gerraty	@echo '$@: a regular command'
50*759b177aSSimon J. Gerraty
51*759b177aSSimon J. Gerraty
52*759b177aSSimon J. Gerraty# expect: do-error-not-ignored: successful
53*759b177aSSimon J. Gerraty# expect-not: do-error-not-ignored: after an error
54*759b177aSSimon J. Gerratyall: error-not-ignored
55*759b177aSSimon J. Gerratyerror-not-ignored:
56*759b177aSSimon J. Gerraty	@${MAKE} -f ${MAKEFILE} do-error-not-ignored || :
57*759b177aSSimon J. Gerratydo-error-not-ignored:
58*759b177aSSimon J. Gerraty	@echo '$@: successful'; exit 13
59*759b177aSSimon J. Gerraty	@echo '$@: after an error'
60