xref: /freebsd/contrib/bmake/unit-tests/opt-debug-jobs.mk (revision 02e9120893770924227138ba49df1edb3896112a)
1# $NetBSD: opt-debug-jobs.mk,v 1.5 2020/11/12 21:54:52 rillig Exp $
2#
3# Tests for the -dj command line option, which adds debug logging about
4# running jobs in multiple shells.
5
6.MAKEFLAGS: -dj
7
8# Run in parallel mode since the debug logging is more interesting there
9# than in compat mode.
10.MAKEFLAGS: -j1
11
12all:
13	# Only the actual command is logged.
14	# To see the evaluation of the variable expressions, use -dv.
15	: ${:Uexpanded} expression
16
17	# Undefined variables expand to empty strings.
18	# Multiple spaces are preserved in the command, as they might be
19	# significant.
20	: ${UNDEF} variable
21
22	# In the debug output, single quotes are not escaped, even though
23	# the whole command is enclosed in single quotes as well.
24	# This allows to copy and paste the whole command, without having
25	# to unescape anything.
26	: 'single' and "double" quotes
27
28	# Avoid a race condition in the debug output.  Without sleeping,
29	# it is not guaranteed that the two lines "exited/stopped" and
30	# "JobFinish" are output earlier than the stdout of the actual shell
31	# commands.  The '@' prefix avoids that this final command gets into
32	# another race condition with the "exited/stopped" line.
33	@sleep 1
34