Module Name: src
Committed By: rillig
Date: Sat Dec 12 15:06:11 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: sh-errctl.exp sh-errctl.mk
Log Message:
make(1): add test for a shell with error control
None of the predefined shells has error control, and the corresponding
code had not been covered by the existing unit tests.
To generate a diff of this commit:
cvs rdiff -u -r1.989 -r1.990 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/sh-errctl.exp \
src/usr.bin/make/unit-tests/sh-errctl.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.989 src/distrib/sets/lists/tests/mi:1.990
--- src/distrib/sets/lists/tests/mi:1.989 Sat Dec 12 03:03:14 2020
+++ src/distrib/sets/lists/tests/mi Sat Dec 12 15:06:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.989 2020/12/12 03:03:14 pgoyette Exp $
+# $NetBSD: mi,v 1.990 2020/12/12 15:06:11 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -5278,6 +5278,8 @@
./usr/tests/usr.bin/make/unit-tests/recursive.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/sh-dots.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/sh-dots.mk tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sh-errctl.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sh-errctl.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/sh-flags.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/sh-flags.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/sh-jobs-error.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.244 src/usr.bin/make/unit-tests/Makefile:1.245
--- src/usr.bin/make/unit-tests/Makefile:1.244 Thu Dec 10 17:06:13 2020
+++ src/usr.bin/make/unit-tests/Makefile Sat Dec 12 15:06:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.244 2020/12/10 17:06:13 rillig Exp $
+# $NetBSD: Makefile,v 1.245 2020/12/12 15:06:11 rillig Exp $
#
# Unit tests for make(1)
#
@@ -262,6 +262,7 @@ TESTS+= # posix1 # broken by reverting
TESTS+= recursive
TESTS+= sh
TESTS+= sh-dots
+TESTS+= sh-errctl
TESTS+= sh-flags
TESTS+= sh-jobs
TESTS+= sh-jobs-error
@@ -484,6 +485,7 @@ SED_CMDS.sh-dots= -e 's,^.*\.\.\.:.*,<n
# For Compat_RunCommand, useShell == TRUE.
SED_CMDS.sh-dots+= -e 's,^make: exec(\(.*\)) failed (.*)$$,<not found: \1>,'
SED_CMDS.sh-dots+= -e 's,^\(\*\*\* Error code \)[1-9][0-9]*,\1<nonzero>,'
+SED_CMDS.sh-errctl= ${STD_SED_CMDS.dj}
SED_CMDS.sh-flags= ${STD_SED_CMDS.hide-from-output}
SED_CMDS.suff-main+= ${STD_SED_CMDS.dg1}
SED_CMDS.suff-main-several+= ${STD_SED_CMDS.dg1}
@@ -521,7 +523,7 @@ unexport-env.rawout: export.mk
# Some standard sed commands, to be used in the SED_CMDS above.
-# Omit details from the output of the -dg1 option such as process IDs.
+# Omit details such as process IDs from the output of the -dg1 option.
STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,<curdir>,'
STD_SED_CMDS.dg1+= -e 's, ${DEFSYSPATH:U/usr/share/mk}$$, <defsyspath>,'
STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 <details omitted>,'
@@ -529,6 +531,15 @@ STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z
STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 <details omitted>,'
STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 <details omitted>,'
+# Omit details such as process IDs from the output of the -dj option.
+STD_SED_CMDS.dj= \
+ -e 's,^\(Job_TokenWithdraw\)([0-9]*),\1(<pid>),' \
+ -e 's,^([0-9][0-9]*) \(withdrew token\),(<pid>) \1,' \
+ -e 's, \(pid\) [0-9][0-9]*, \1 <pid>,' \
+ -e 's,^\(Process\) [0-9][0-9]*,\1 <pid>,' \
+ -e 's,^\(JobFinish:\) [0-9][0-9]*,\1 <pid>,' \
+ -e 's,^\( Command:\) .*,\1 <shell>,'
+
# Reduce the noise for tests running with the -n option, since there is no
# other way to suppress the echoing of the commands.
STD_SED_CMDS.hide-from-output= \
Added files:
Index: src/usr.bin/make/unit-tests/sh-errctl.exp
diff -u /dev/null src/usr.bin/make/unit-tests/sh-errctl.exp:1.1
--- /dev/null Sat Dec 12 15:06:11 2020
+++ src/usr.bin/make/unit-tests/sh-errctl.exp Sat Dec 12 15:06:11 2020
@@ -0,0 +1,29 @@
+job_pipe -1 -1, maxjobs 1, tokens 1, compat 0
+Job_TokenWithdraw(<pid>): aborting 0, running 0
+(<pid>) withdrew token
+# echo off
+echo silent
+# echo on
+# echo off
+# error checking off
+set +e
+# echo on
+echo ignerr; false
+# echo off
+# error checking on
+set -e
+# echo on
+echo always
+Running all
+ Command: <shell>
+JobExec(all): pid <pid> added to jobs table
+job table @ job started
+job 0, status 3, flags ---, pid <pid>
+silent
+ignerr
+always
+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/sh-errctl.mk
diff -u /dev/null src/usr.bin/make/unit-tests/sh-errctl.mk:1.1
--- /dev/null Sat Dec 12 15:06:11 2020
+++ src/usr.bin/make/unit-tests/sh-errctl.mk Sat Dec 12 15:06:11 2020
@@ -0,0 +1,26 @@
+# $NetBSD: sh-errctl.mk,v 1.1 2020/12/12 15:06:11 rillig Exp $
+#
+# Test a shell with error control. This only works in jobs mode; in compat
+# mode, the default shell is always used, see InitShellNameAndPath.
+#
+# There is a subtle difference between error control and echo control.
+# With error control, each simple command is checked, whereas with echo
+# control, only the last command from each line is checked. A shell command
+# line that behaves differently in these two modes is "false; true". In
+# error control mode, this fails, while in echo control mode, it succeeds.
+
+.MAKEFLAGS: -j1 -dj
+
+.SHELL: \
+ name="sh" \
+ path="${.SHELL}" \
+ hasErrCtl="yes" \
+ check="\# error checking on\nset -e" \
+ ignore="\# error checking off\nset +e" \
+ echo="\# echo on" \
+ quiet="\# echo off"
+
+all:
+ @echo silent
+ -echo ignerr; false
+ +echo always