Module Name:    src
Committed By:   rillig
Date:           Wed Dec  9 00:25:01 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile
Added Files:
        src/usr.bin/make/unit-tests: opt-jobs-no-action.exp
            opt-jobs-no-action.mk

Log Message:
make(1): add test for combining -j1 with -n


To generate a diff of this commit:
cvs rdiff -u -r1.985 -r1.986 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.240 -r1.241 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/opt-jobs-no-action.exp \
    src/usr.bin/make/unit-tests/opt-jobs-no-action.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.985 src/distrib/sets/lists/tests/mi:1.986
--- src/distrib/sets/lists/tests/mi:1.985	Mon Dec  7 21:35:43 2020
+++ src/distrib/sets/lists/tests/mi	Wed Dec  9 00:25:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.985 2020/12/07 21:35:43 rillig Exp $
+# $NetBSD: mi,v 1.986 2020/12/09 00:25:00 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5217,6 +5217,8 @@
 ./usr/tests/usr.bin/make/unit-tests/opt-include-dir.mk				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs-internal.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs-internal.mk			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-jobs-no-action.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/opt-jobs-no-action.mk			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs.exp				tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-jobs.mk					tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/opt-keep-going-multiple.exp			tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.240 src/usr.bin/make/unit-tests/Makefile:1.241
--- src/usr.bin/make/unit-tests/Makefile:1.240	Mon Dec  7 22:27:56 2020
+++ src/usr.bin/make/unit-tests/Makefile	Wed Dec  9 00:25:00 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.240 2020/12/07 22:27:56 rillig Exp $
+# $NetBSD: Makefile,v 1.241 2020/12/09 00:25:00 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -236,6 +236,7 @@ TESTS+=		opt-ignore
 TESTS+=		opt-include-dir
 TESTS+=		opt-jobs
 TESTS+=		opt-jobs-internal
+TESTS+=		opt-jobs-no-action
 TESTS+=		opt-keep-going
 TESTS+=		opt-keep-going-multiple
 TESTS+=		opt-m-include-dir

Added files:

Index: src/usr.bin/make/unit-tests/opt-jobs-no-action.exp
diff -u /dev/null src/usr.bin/make/unit-tests/opt-jobs-no-action.exp:1.1
--- /dev/null	Wed Dec  9 00:25:01 2020
+++ src/usr.bin/make/unit-tests/opt-jobs-no-action.exp	Wed Dec  9 00:25:00 2020
@@ -0,0 +1,15 @@
+# .echoOff
+# .errOnOrEcho
+echo "false regular"
+# .errExit
+{ false regular 
+} || exit $?
+# .echoOn
+# .errExit
+{ : silent 
+} || exit $?
+# .echoOn
+false ignore-errors
+echo run despite the -n option
+run despite the -n option
+exit status 0
Index: src/usr.bin/make/unit-tests/opt-jobs-no-action.mk
diff -u /dev/null src/usr.bin/make/unit-tests/opt-jobs-no-action.mk:1.1
--- /dev/null	Wed Dec  9 00:25:01 2020
+++ src/usr.bin/make/unit-tests/opt-jobs-no-action.mk	Wed Dec  9 00:25:00 2020
@@ -0,0 +1,55 @@
+# $NetBSD: opt-jobs-no-action.mk,v 1.1 2020/12/09 00:25:00 rillig Exp $
+#
+# Tests for the combination of the options -j and -n, which prints the
+# commands instead of actually running them.
+#
+# The format of the output differs from the output of only the -n option,
+# without the -j.  This is because all this code is implemented twice, once
+# in compat.c and once in job.c.
+
+.MAKEFLAGS: -j1 -n
+
+# Change the templates for running the commands in jobs mode, to make it
+# easier to see what actually happens.
+#
+# The shell attributes are handled by Job_ParseShell.
+# The shell attributes 'quiet' and 'echo' don't need a trailing newline,
+# this is handled by the [0] != '\0' checks in Job_ParseShell.
+# The '\#' is handled by ParseGetLine.
+# The '\n' is handled by Str_Words in Job_ParseShell.
+# The '$$' is handled by Var_Subst in ParseDependency.
+.SHELL: \
+	name=sh \
+	path=${.SHELL} \
+	quiet="\# .echoOff" \
+	echo="\# .echoOn" \
+	filter="\# .noPrint\n" \
+	check="\# .errOnOrEcho\n""echo \"%s\"\n" \
+	ignore="\# .errOffOrExecIgnore\n""%s\n" \
+	errout="\# .errExit\n""{ %s \n} || exit $$?\n"
+
+all:
+	# The following command is regular, it is printed twice:
+	# - first using the template shell.errOnOrEcho,
+	# - then using the template shell.errExit.
+	false regular
+
+	# The following command is silent, it is printed once, using the
+	# template shell.errExit.
+	@: silent
+
+	# The following command ignores errors, it is printed once, using
+	# the default template for cmdTemplate, which is "%s\n".
+	# XXX: Why is it not printed using shell.errOnOrEcho as well?
+	# XXX: The '-' should not influence the echoing of the command.
+	-false ignore-errors
+
+	# The following command ignores the -n command line option, it is
+	# not handled by the Job module but by the Compat module, see the
+	# '!silent' in Compat_RunCommand.
+	+echo run despite the -n option
+
+	# TODO: test all 8 combinations of '-', '+', '@'.
+	# TODO: for each of the above test, test '-true' and '-false'.
+	# The code with its many branches feels like a big mess.
+	# See opt-jobs.mk for the corresponding tests without the -n option.

Reply via email to