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 interrupting a...



details:   https://anonhg.NetBSD.org/src/rev/b20ad822662e
branches:  trunk
changeset: 937894:b20ad822662e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Aug 28 15:40:53 2020 +0000

description:
make(1): add test for interrupting a command

diffstat:

 distrib/sets/lists/tests/mi               |   4 ++-
 usr.bin/make/unit-tests/Makefile          |   3 +-
 usr.bin/make/unit-tests/cmd-interrupt.exp |  17 +++++++++++++++
 usr.bin/make/unit-tests/cmd-interrupt.mk  |  35 +++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 2 deletions(-)

diffs (95 lines):

diff -r 69d26c259e8a -r b20ad822662e distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Aug 28 15:35:34 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Aug 28 15:40:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.911 2020/08/28 03:51:06 rillig Exp $
+# $NetBSD: mi,v 1.912 2020/08/28 15:40:53 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4540,6 +4540,8 @@
 ./usr/tests/usr.bin/make/unit-tests/Makefile   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/archive.exp        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cmd-interrupt.exp  tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/cmd-interrupt.mk   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cmdline.exp        tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/cmdline.mk tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/comment.exp        tests-usr.bin-tests     compattestfile,atf
diff -r 69d26c259e8a -r b20ad822662e usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Fri Aug 28 15:35:34 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Fri Aug 28 15:40:53 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.123 2020/08/28 04:05:35 rillig Exp $
+# $NetBSD: Makefile,v 1.124 2020/08/28 15:40:53 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -36,6 +36,7 @@
 # Any test that is commented out must be ignored in
 # src/tests/usr.bin/make/t_make.sh as well.
 TESTS+=                # archive       # broken on FreeBSD, enabled in t_make.sh
+TESTS+=                cmd-interrupt
 TESTS+=                cmdline
 TESTS+=                comment
 TESTS+=                cond-cmp-numeric
diff -r 69d26c259e8a -r b20ad822662e usr.bin/make/unit-tests/cmd-interrupt.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cmd-interrupt.exp Fri Aug 28 15:40:53 2020 +0000
@@ -0,0 +1,17 @@
+make  -r -k  -f cmd-interrupt.mk cmd-interrupt-ordinary || true
+> cmd-interrupt-ordinary
+kill -INT $$
+*** Signal 2 (continuing)
+
+Stop.
+make: stopped in unit-tests
+ok
+make  -r -k  -f cmd-interrupt.mk cmd-interrupt-phony || true
+> cmd-interrupt-phony
+kill -INT $$
+*** Signal 2 (continuing)
+
+Stop.
+make: stopped in unit-tests
+ok
+exit status 0
diff -r 69d26c259e8a -r b20ad822662e usr.bin/make/unit-tests/cmd-interrupt.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/cmd-interrupt.mk  Fri Aug 28 15:40:53 2020 +0000
@@ -0,0 +1,35 @@
+# $NetBSD: cmd-interrupt.mk,v 1.1 2020/08/28 15:40:53 rillig Exp $
+#
+# Tests for interrupting a command.
+#
+# If a command is interrupted (usually by the user, here by itself), the
+# target is removed.  This is to avoid having an unfinished target that
+# would be newer than all of its sources and would therefore not be
+# tried again in the next run.
+#
+# For .PHONY targets, there is usually no corresponding file and therefore
+# nothing that could be removed.  These .PHONY targets need to ensure for
+# themselves that interrupting them does not leave an inconsistent state
+# behind.
+
+SELF:= ${.PARSEDIR}/${.PARSEFILE}
+
+_!=    rm -f cmd-interrupt-ordinary cmd-interrupt-phony
+
+all: interrupt-ordinary interrupt-phony
+
+interrupt-ordinary:
+       ${.MAKE} ${MAKEFLAGS} -f ${SELF} cmd-interrupt-ordinary || true
+       @echo ${exists(cmd-interrupt-ordinary) :? error : ok }
+
+interrupt-phony:
+       ${.MAKE} ${MAKEFLAGS} -f ${SELF} cmd-interrupt-phony || true
+       @echo ${exists(cmd-interrupt-phony) :? ok : error }
+
+cmd-interrupt-ordinary:
+       > ${.TARGET}
+       kill -INT $$$$
+
+cmd-interrupt-phony: .PHONY
+       > ${.TARGET}
+       kill -INT $$$$



Home | Main Index | Thread Index | Old Index