Module Name: src
Committed By: rillig
Date: Sat Oct 3 08:16:53 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-jobs.exp
opt-debug-jobs.mk
Log Message:
make(1): add test for the -dj debug option
To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-debug-jobs.exp \
src/usr.bin/make/unit-tests/opt-debug-jobs.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.156 src/usr.bin/make/unit-tests/Makefile:1.157
--- src/usr.bin/make/unit-tests/Makefile:1.156 Fri Oct 2 20:34:59 2020
+++ src/usr.bin/make/unit-tests/Makefile Sat Oct 3 08:16:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.156 2020/10/02 20:34:59 rillig Exp $
+# $NetBSD: Makefile,v 1.157 2020/10/03 08:16:53 rillig Exp $
#
# Unit tests for make(1)
#
@@ -403,6 +403,10 @@ SED_CMDS.opt-debug-graph1= \
SED_CMDS.opt-debug-graph1+= \
-e '/Global Variables:/,/Suffixes:/d'
SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
+SED_CMDS.opt-debug-jobs= -e 's,([0-9][0-9]*),(<pid>),'
+SED_CMDS.opt-debug-jobs+= -e 's,pid [0-9][0-9]*,pid <pid>,'
+SED_CMDS.opt-debug-jobs+= -e 's,Process [0-9][0-9]*,Process <pid>,'
+SED_CMDS.opt-debug-jobs+= -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
SED_CMDS.varmod-subst-regex+= \
-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
Index: src/usr.bin/make/unit-tests/opt-debug-jobs.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.1 src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.2
--- src/usr.bin/make/unit-tests/opt-debug-jobs.exp:1.1 Sat Sep 5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-jobs.exp Sat Oct 3 08:16:53 2020
@@ -1 +1,25 @@
+job_pipe -1 -1, maxjobs 1, tokens 1, compat 0
+Job_TokenWithdraw(<pid>): aborting 0, running 0
+(<pid>) withdrew token
+echo ": expanded expression"
+{ : expanded expression
+} || exit $?
+echo ": variable"
+{ : variable
+} || exit $?
+echo ": 'single' and \"double\" quotes"
+{ : 'single' and "double" quotes
+} || exit $?
+Running all locally
+ Command: sh -q
+JobExec(all): pid <pid> added to jobs table
+job table @ job started
+job 0, status 3, flags 0, pid <pid>
+: expanded expression
+: variable
+: 'single' and "double" quotes
+Process <pid> exited/stopped status 0.
+JobFinish: <pid> [all], status 0
+Job_TokenWithdraw(<pid>): aborting 0, running 0
+(<pid>) withdrew token
exit status 0
Index: src/usr.bin/make/unit-tests/opt-debug-jobs.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.1 src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.2
--- src/usr.bin/make/unit-tests/opt-debug-jobs.mk:1.1 Sat Sep 5 06:20:51 2020
+++ src/usr.bin/make/unit-tests/opt-debug-jobs.mk Sat Oct 3 08:16:53 2020
@@ -1,9 +1,26 @@
-# $NetBSD: opt-debug-jobs.mk,v 1.1 2020/09/05 06:20:51 rillig Exp $
+# $NetBSD: opt-debug-jobs.mk,v 1.2 2020/10/03 08:16:53 rillig Exp $
#
-# Tests for the -da command line option, which adds debug logging about
+# Tests for the -dj command line option, which adds debug logging about
# running jobs in multiple shells.
-# TODO: Implementation
+.MAKEFLAGS: -dj
+
+# Run in parallel mode since the debug logging is more interesting there
+# than in compat mode.
+.MAKEFLAGS: -j1
all:
- @:;
+ # Only the actual command is logged.
+ # To see the evaluation of the variable expressions, use -dv.
+ : ${:Uexpanded} expression
+
+ # Undefined variables expand to empty strings.
+ # Multiple spaces are preserved in the command, as they might be
+ # significant.
+ : ${UNDEF} variable
+
+ # In the debug output, single quotes are not escaped, even though
+ # the whole command is enclosed in single quotes as well.
+ # This allows to copy and paste the whole command, without having
+ # to unescape anything.
+ : 'single' and "double" quotes