Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for combining -j1 ...



details:   https://anonhg.NetBSD.org/src/rev/1ac6685e9b32
branches:  trunk
changeset: 1016987:1ac6685e9b32
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 09 00:25:00 2020 +0000

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

diffstat:

 distrib/sets/lists/tests/mi                    |   4 +-
 usr.bin/make/unit-tests/Makefile               |   3 +-
 usr.bin/make/unit-tests/opt-jobs-no-action.exp |  15 +++++++
 usr.bin/make/unit-tests/opt-jobs-no-action.mk  |  55 ++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 2 deletions(-)

diffs (113 lines):

diff -r f684c1324b3d -r 1ac6685e9b32 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Wed Dec 09 00:03:32 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Wed Dec 09 00:25:00 2020 +0000
@@ -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
diff -r f684c1324b3d -r 1ac6685e9b32 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Wed Dec 09 00:03:32 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Wed Dec 09 00:25:00 2020 +0000
@@ -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-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
diff -r f684c1324b3d -r 1ac6685e9b32 usr.bin/make/unit-tests/opt-jobs-no-action.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/opt-jobs-no-action.exp    Wed Dec 09 00:25:00 2020 +0000
@@ -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
diff -r f684c1324b3d -r 1ac6685e9b32 usr.bin/make/unit-tests/opt-jobs-no-action.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/opt-jobs-no-action.mk     Wed Dec 09 00:25:00 2020 +0000
@@ -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.



Home | Main Index | Thread Index | Old Index