1*d5e0a182SSimon J. Gerraty# $NetBSD: opt-debug-jobs.mk,v 1.6 2023/11/19 21:47:52 rillig Exp $
2956e45f6SSimon J. Gerraty#
3956e45f6SSimon J. Gerraty# Tests for the -dj command line option, which adds debug logging about
4956e45f6SSimon J. Gerraty# running jobs in multiple shells.
5956e45f6SSimon J. Gerraty
6956e45f6SSimon J. Gerraty.MAKEFLAGS: -dj
7956e45f6SSimon J. Gerraty
8956e45f6SSimon J. Gerraty# Run in parallel mode since the debug logging is more interesting there
9956e45f6SSimon J. Gerraty# than in compat mode.
10956e45f6SSimon J. Gerraty.MAKEFLAGS: -j1
11956e45f6SSimon J. Gerraty
12956e45f6SSimon J. Gerratyall:
13956e45f6SSimon J. Gerraty	# Only the actual command is logged.
14*d5e0a182SSimon J. Gerraty	# To see the evaluation of the expressions, use -dv.
15956e45f6SSimon J. Gerraty	: ${:Uexpanded} expression
16956e45f6SSimon J. Gerraty
17956e45f6SSimon J. Gerraty	# Undefined variables expand to empty strings.
18956e45f6SSimon J. Gerraty	# Multiple spaces are preserved in the command, as they might be
19956e45f6SSimon J. Gerraty	# significant.
20956e45f6SSimon J. Gerraty	: ${UNDEF} variable
21956e45f6SSimon J. Gerraty
22956e45f6SSimon J. Gerraty	# In the debug output, single quotes are not escaped, even though
23956e45f6SSimon J. Gerraty	# the whole command is enclosed in single quotes as well.
24956e45f6SSimon J. Gerraty	# This allows to copy and paste the whole command, without having
25956e45f6SSimon J. Gerraty	# to unescape anything.
26956e45f6SSimon J. Gerraty	: 'single' and "double" quotes
27e2eeea75SSimon J. Gerraty
28e2eeea75SSimon J. Gerraty	# Avoid a race condition in the debug output.  Without sleeping,
29e2eeea75SSimon J. Gerraty	# it is not guaranteed that the two lines "exited/stopped" and
30e2eeea75SSimon J. Gerraty	# "JobFinish" are output earlier than the stdout of the actual shell
31e2eeea75SSimon J. Gerraty	# commands.  The '@' prefix avoids that this final command gets into
32e2eeea75SSimon J. Gerraty	# another race condition with the "exited/stopped" line.
33e2eeea75SSimon J. Gerraty	@sleep 1
34