Fri Aug 28 15:40:54 2020 UTC ()
make(1): add test for interrupting a command


(rillig)
diff -r1.911 -r1.912 src/distrib/sets/lists/tests/mi
diff -r1.123 -r1.124 src/usr.bin/make/unit-tests/Makefile
diff -r0 -r1.1 src/usr.bin/make/unit-tests/cmd-interrupt.exp
diff -r0 -r1.1 src/usr.bin/make/unit-tests/cmd-interrupt.mk

cvs diff -r1.911 -r1.912 src/distrib/sets/lists/tests/mi (expand / switch to unified diff)

--- src/distrib/sets/lists/tests/mi 2020/08/28 03:51:06 1.911
+++ src/distrib/sets/lists/tests/mi 2020/08/28 15:40:53 1.912
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: mi,v 1.911 2020/08/28 03:51:06 rillig Exp $ 1# $NetBSD: mi,v 1.912 2020/08/28 15:40:53 rillig Exp $
2# 2#
3# Note: don't delete entries from here - mark them as "obsolete" instead. 3# Note: don't delete entries from here - mark them as "obsolete" instead.
4# 4#
5./etc/mtree/set.tests tests-sys-root 5./etc/mtree/set.tests tests-sys-root
6./usr/libdata/debug/usr/tests tests-base-debug compattestdir 6./usr/libdata/debug/usr/tests tests-base-debug compattestdir
7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf 7./usr/libdata/debug/usr/tests/atf tests-atf-debug compattestfile,atf
8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf 8./usr/libdata/debug/usr/tests/atf/atf-c tests-atf-debug compattestfile,atf
9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf 9./usr/libdata/debug/usr/tests/atf/atf-c++ tests-atf-debug compattestfile,atf
10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf 10./usr/libdata/debug/usr/tests/atf/atf-c++/detail tests-atf-debug compattestfile,atf
11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf 11./usr/libdata/debug/usr/tests/atf/atf-c/detail tests-atf-debug compattestfile,atf
12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete 12./usr/libdata/debug/usr/tests/atf/atf-compile tests-obsolete obsolete
13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete 13./usr/libdata/debug/usr/tests/atf/atf-report tests-obsolete obsolete
14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete 14./usr/libdata/debug/usr/tests/atf/atf-run tests-obsolete obsolete
@@ -4530,26 +4530,28 @@ @@ -4530,26 +4530,28 @@
4530./usr/tests/usr.bin/make/d_qequals.mk tests-obsolete obsolete,atf 4530./usr/tests/usr.bin/make/d_qequals.mk tests-obsolete obsolete,atf
4531./usr/tests/usr.bin/make/d_qequals.out tests-obsolete obsolete,atf 4531./usr/tests/usr.bin/make/d_qequals.out tests-obsolete obsolete,atf
4532./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf 4532./usr/tests/usr.bin/make/d_ternary.mk tests-obsolete obsolete,atf
4533./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf 4533./usr/tests/usr.bin/make/d_ternary.out tests-obsolete obsolete,atf
4534./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf 4534./usr/tests/usr.bin/make/d_unmatchedvarparen.mk tests-obsolete obsolete,atf
4535./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf 4535./usr/tests/usr.bin/make/d_unmatchedvarparen.out tests-obsolete obsolete,atf
4536./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf 4536./usr/tests/usr.bin/make/d_varcmd.mk tests-obsolete obsolete,atf
4537./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf 4537./usr/tests/usr.bin/make/d_varcmd.out tests-obsolete obsolete,atf
4538./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf 4538./usr/tests/usr.bin/make/t_make tests-usr.bin-tests compattestfile,atf
4539./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf 4539./usr/tests/usr.bin/make/unit-tests tests-usr.bin-tests compattestfile,atf
4540./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf 4540./usr/tests/usr.bin/make/unit-tests/Makefile tests-usr.bin-tests compattestfile,atf
4541./usr/tests/usr.bin/make/unit-tests/archive.exp tests-usr.bin-tests compattestfile,atf 4541./usr/tests/usr.bin/make/unit-tests/archive.exp tests-usr.bin-tests compattestfile,atf
4542./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests compattestfile,atf 4542./usr/tests/usr.bin/make/unit-tests/archive.mk tests-usr.bin-tests compattestfile,atf
 4543./usr/tests/usr.bin/make/unit-tests/cmd-interrupt.exp tests-usr.bin-tests compattestfile,atf
 4544./usr/tests/usr.bin/make/unit-tests/cmd-interrupt.mk tests-usr.bin-tests compattestfile,atf
4543./usr/tests/usr.bin/make/unit-tests/cmdline.exp tests-usr.bin-tests compattestfile,atf 4545./usr/tests/usr.bin/make/unit-tests/cmdline.exp tests-usr.bin-tests compattestfile,atf
4544./usr/tests/usr.bin/make/unit-tests/cmdline.mk tests-usr.bin-tests compattestfile,atf 4546./usr/tests/usr.bin/make/unit-tests/cmdline.mk tests-usr.bin-tests compattestfile,atf
4545./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf 4547./usr/tests/usr.bin/make/unit-tests/comment.exp tests-usr.bin-tests compattestfile,atf
4546./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf 4548./usr/tests/usr.bin/make/unit-tests/comment.mk tests-usr.bin-tests compattestfile,atf
4547./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp tests-usr.bin-tests compattestfile,atf 4549./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp tests-usr.bin-tests compattestfile,atf
4548./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk tests-usr.bin-tests compattestfile,atf 4550./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk tests-usr.bin-tests compattestfile,atf
4549./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-ge.exp tests-usr.bin-tests compattestfile,atf 4551./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-ge.exp tests-usr.bin-tests compattestfile,atf
4550./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk tests-usr.bin-tests compattestfile,atf 4552./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-ge.mk tests-usr.bin-tests compattestfile,atf
4551./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-gt.exp tests-usr.bin-tests compattestfile,atf 4553./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-gt.exp tests-usr.bin-tests compattestfile,atf
4552./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk tests-usr.bin-tests compattestfile,atf 4554./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-gt.mk tests-usr.bin-tests compattestfile,atf
4553./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-le.exp tests-usr.bin-tests compattestfile,atf 4555./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-le.exp tests-usr.bin-tests compattestfile,atf
4554./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk tests-usr.bin-tests compattestfile,atf 4556./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-le.mk tests-usr.bin-tests compattestfile,atf
4555./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-lt.exp tests-usr.bin-tests compattestfile,atf 4557./usr/tests/usr.bin/make/unit-tests/cond-cmp-numeric-lt.exp tests-usr.bin-tests compattestfile,atf

cvs diff -r1.123 -r1.124 src/usr.bin/make/unit-tests/Makefile (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/Makefile 2020/08/28 04:05:35 1.123
+++ src/usr.bin/make/unit-tests/Makefile 2020/08/28 15:40:53 1.124
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: Makefile,v 1.123 2020/08/28 04:05:35 rillig Exp $ 1# $NetBSD: Makefile,v 1.124 2020/08/28 15:40:53 rillig Exp $
2# 2#
3# Unit tests for make(1) 3# Unit tests for make(1)
4# 4#
5# The main targets are: 5# The main targets are:
6# 6#
7# all: 7# all:
8# run all the tests 8# run all the tests
9# test: 9# test:
10# run 'all', and compare to expected results 10# run 'all', and compare to expected results
11# accept: 11# accept:
12# move generated output to expected results 12# move generated output to expected results
13# 13#
14# Settable variables 14# Settable variables
@@ -26,26 +26,27 @@ @@ -26,26 +26,27 @@
26# Any added files must also be added to src/distrib/sets/lists/tests/mi. 26# Any added files must also be added to src/distrib/sets/lists/tests/mi.
27# To do that, just run "make sync-mi" in this directory. 27# To do that, just run "make sync-mi" in this directory.
28# 28#
29# A few *.mk files are helper files for other tests (such as include-sub.mk) 29# A few *.mk files are helper files for other tests (such as include-sub.mk)
30# and are thus not added to TESTS. Such files must be ignored in 30# and are thus not added to TESTS. Such files must be ignored in
31# src/tests/usr.bin/make/t_make.sh. 31# src/tests/usr.bin/make/t_make.sh.
32# 32#
33 33
34# Each test is in a sub-makefile. 34# Each test is in a sub-makefile.
35# Keep the list sorted. 35# Keep the list sorted.
36# Any test that is commented out must be ignored in 36# Any test that is commented out must be ignored in
37# src/tests/usr.bin/make/t_make.sh as well. 37# src/tests/usr.bin/make/t_make.sh as well.
38TESTS+= # archive # broken on FreeBSD, enabled in t_make.sh 38TESTS+= # archive # broken on FreeBSD, enabled in t_make.sh
 39TESTS+= cmd-interrupt
39TESTS+= cmdline 40TESTS+= cmdline
40TESTS+= comment 41TESTS+= comment
41TESTS+= cond-cmp-numeric 42TESTS+= cond-cmp-numeric
42TESTS+= cond-cmp-numeric-eq 43TESTS+= cond-cmp-numeric-eq
43TESTS+= cond-cmp-numeric-ge 44TESTS+= cond-cmp-numeric-ge
44TESTS+= cond-cmp-numeric-gt 45TESTS+= cond-cmp-numeric-gt
45TESTS+= cond-cmp-numeric-le 46TESTS+= cond-cmp-numeric-le
46TESTS+= cond-cmp-numeric-lt 47TESTS+= cond-cmp-numeric-lt
47TESTS+= cond-cmp-numeric-ne 48TESTS+= cond-cmp-numeric-ne
48TESTS+= cond-cmp-string 49TESTS+= cond-cmp-string
49TESTS+= cond-func 50TESTS+= cond-func
50TESTS+= cond-func-commands 51TESTS+= cond-func-commands
51TESTS+= cond-func-defined 52TESTS+= cond-func-defined

File Added: src/usr.bin/make/unit-tests/cmd-interrupt.exp
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

File Added: src/usr.bin/make/unit-tests/cmd-interrupt.mk
# $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 $$$$