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 a shell with e...
details: https://anonhg.NetBSD.org/src/rev/bf3ab52115c7
branches: trunk
changeset: 957832:bf3ab52115c7
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Dec 12 15:06:11 2020 +0000
description:
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.
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
usr.bin/make/unit-tests/Makefile | 15 +++++++++++++--
usr.bin/make/unit-tests/sh-errctl.exp | 29 +++++++++++++++++++++++++++++
usr.bin/make/unit-tests/sh-errctl.mk | 26 ++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 3 deletions(-)
diffs (131 lines):
diff -r 2f042ebc126a -r bf3ab52115c7 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sat Dec 12 13:13:34 2020 +0000
+++ b/distrib/sets/lists/tests/mi Sat Dec 12 15:06:11 2020 +0000
@@ -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
diff -r 2f042ebc126a -r bf3ab52115c7 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Sat Dec 12 13:13:34 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile Sat Dec 12 15:06:11 2020 +0000
@@ -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+= recursive
TESTS+= sh
TESTS+= sh-dots
+TESTS+= sh-errctl
TESTS+= sh-flags
TESTS+= sh-jobs
TESTS+= sh-jobs-error
@@ -484,6 +485,7 @@
# 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 @@
# 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,^\(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= \
diff -r 2f042ebc126a -r bf3ab52115c7 usr.bin/make/unit-tests/sh-errctl.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/sh-errctl.exp Sat Dec 12 15:06:11 2020 +0000
@@ -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
diff -r 2f042ebc126a -r bf3ab52115c7 usr.bin/make/unit-tests/sh-errctl.mk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/sh-errctl.mk Sat Dec 12 15:06:11 2020 +0000
@@ -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
Home |
Main Index |
Thread Index |
Old Index