xref: /freebsd/contrib/bmake/unit-tests/sh-dots.mk (revision 18f21f0355481283ceef0ec10e99554f44c205c2)
1# $NetBSD: sh-dots.mk,v 1.3 2020/10/25 22:04:24 rillig Exp $
2#
3# Tests for the special shell command line "...", which does not run the
4# commands below it but appends them to the list of commands that are run
5# at the end.
6
7.MAKEFLAGS: -d0			# switch stdout to being line-buffered
8
9all: first hidden repeated commented indirect indirect-space
10
11# The ${.TARGET} correctly expands to the target name, even though the
12# commands are run separately from the main commands.
13first:
14	@echo first ${.TARGET}
15	...
16	@echo first delayed ${.TARGET}
17
18# The dots cannot be prefixed by the usual @-+ characters.
19# They must be written exactly as dots.
20hidden: .IGNORE
21	@echo hidden ${.TARGET}
22	@...
23	@echo hidden delayed ${.TARGET}
24
25# Since the shell command lines don't recognize '#' as comment character,
26# the "..." is not interpreted specially here.
27commented: .IGNORE
28	@echo commented ${.TARGET}
29	...	# Run the below commands later
30	@echo commented delayed ${.TARGET}
31
32# The dots don't have to be written literally, they can also come from a
33# variable expression.
34indirect:
35	@echo indirect regular
36	${:U...}
37	@echo indirect deferred
38
39# If the dots are followed by a space, that space is part of the command and
40# thus does not defer the command below it.
41indirect-space: .IGNORE
42	@echo indirect-space regular
43	${:U... }
44	@echo indirect-space deferred
45
46
47# The "..." can appear more than once, even though that doesn't make sense.
48# The second "..." is a no-op.
49repeated: .IGNORE
50	@echo repeated ${.TARGET}
51	...
52	@echo repeated delayed ${.TARGET}
53	...
54	@echo repeated delayed twice ${.TARGET}
55