summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2022-02-12 13:17:57 +0000
committerrillig <rillig@NetBSD.org>2022-02-12 13:17:57 +0000
commitbbb4da535cbd4957ef715cb439dbab08437359b3 (patch)
treeec75c3fad67bb516cf234be73a7a17ab64c3c4c4 /usr.bin/make
parent534329e45c81a70e59416145c1789861d98fe951 (diff)
tests/make: document the history of bugs in '-k' mode
Reported in PR#49720 in 2015, fixed independently in compat.c 1.199 from 2020-12-07.
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/unit-tests/Makefile3
-rw-r--r--usr.bin/make/unit-tests/opt-keep-going-indirect.exp32
-rw-r--r--usr.bin/make/unit-tests/opt-keep-going-indirect.mk88
3 files changed, 122 insertions, 1 deletions
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile
index 77687c66707..4b32b0bd879 100644
--- a/usr.bin/make/unit-tests/Makefile
+++ b/usr.bin/make/unit-tests/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.308 2022/02/12 01:15:18 rillig Exp $
+# $NetBSD: Makefile,v 1.309 2022/02/12 13:17:57 rillig Exp $
#
# Unit tests for make(1)
#
@@ -260,6 +260,7 @@ TESTS+= opt-jobs
TESTS+= opt-jobs-internal
TESTS+= opt-jobs-no-action
TESTS+= opt-keep-going
+TESTS+= opt-keep-going-indirect
TESTS+= opt-keep-going-multiple
TESTS+= opt-m-include-dir
TESTS+= opt-no-action
diff --git a/usr.bin/make/unit-tests/opt-keep-going-indirect.exp b/usr.bin/make/unit-tests/opt-keep-going-indirect.exp
new file mode 100644
index 00000000000..0c00c75395f
--- /dev/null
+++ b/usr.bin/make/unit-tests/opt-keep-going-indirect.exp
@@ -0,0 +1,32 @@
+direct compat
+false
+*** Error code 1 (continuing)
+
+Stop.
+make: stopped in unit-tests
+exited 1
+
+direct jobs
+false
+*** [direct] Error code 1
+
+make: stopped in unit-tests
+exited 1
+
+indirect compat
+false
+*** Error code 1 (continuing)
+`indirect' not remade because of errors.
+
+Stop.
+make: stopped in unit-tests
+exited 1
+
+indirect jobs
+false
+*** [direct] Error code 1
+
+make: stopped in unit-tests
+exited 1
+
+exit status 0
diff --git a/usr.bin/make/unit-tests/opt-keep-going-indirect.mk b/usr.bin/make/unit-tests/opt-keep-going-indirect.mk
new file mode 100644
index 00000000000..099eee25184
--- /dev/null
+++ b/usr.bin/make/unit-tests/opt-keep-going-indirect.mk
@@ -0,0 +1,88 @@
+# $NetBSD: opt-keep-going-indirect.mk,v 1.1 2022/02/12 13:17:57 rillig Exp $
+#
+# Tests for the -k command line option, which stops building a target as soon
+# as an error is detected, but continues building the other, independent
+# targets, as far as possible.
+#
+# History:
+# In 1993, the exit status for the option '-k' was always 0, even if a
+# a direct or an indirect target failed.
+#
+# Since 2000.12.30.02.05.21, the word '(continuing)' is missing in jobs
+# mode, both for direct as well as indirect targets.
+#
+# Since 2001.10.16.18.50.12, the exit status for a direct failure in
+# compat mode is 1, while jobs mode and indirect failures still return
+# exit status 0. The number of empty lines between the various error
+# messages differs between the modes, for no reason.
+#
+# At 2006.11.17.22.07.39, the exit status for direct failures in both
+# modes and for indirect failures in jobs mode was corrected, leaving
+# only indirect failures in compat mode wrong. On the downside, a
+# failed indirect target in jobs mode was no longer listed as "not
+# remade because of errors".
+#
+# At 2016.08.26.23.28.39, the additional empty lines for a direct
+# failure in compat mode was removed, making it consistent with a direct
+# failure in jobs mode. This left only one inconsistency, in that
+# indirect failures in jobs mode (by far the most common when building
+# large projects) did not produce any empty line.
+#
+# Since 2020.12.07.00.53.30, the exit status is consistently 1 for
+# failures in all 4 modes.
+#
+# Bugs:
+# The output in case of a failure needlessly differs between compat and
+# jobs mode. As of 2022-02-12, compat mode outputs '(continuing)' while
+# jobs mode doesn't. In compat mode, the output does not mention which
+# target failed.
+#
+# See also:
+# https://gnats.netbsd.org/49720
+
+.PHONY: all direct indirect
+
+# The 'set +e' was necessary in 2003, when the shell was run with '-e' by
+# default.
+# The 'env -i' prevents that the environment variable MAKEFLAGS is passed down
+# to the child processes.
+all:
+ @echo 'direct compat'
+ @set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct; echo "exited $$?"
+ @echo
+
+ @echo 'direct jobs'
+ @set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct -j1; echo "exited $$?"
+ @echo
+
+ @echo 'indirect compat'
+ @set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect; echo "exited $$?"
+ @echo
+
+ @echo 'indirect jobs'
+ @set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect -j1; echo "exited $$?"
+ @echo
+
+indirect: direct
+direct:
+ false
+
+# TODO: Mention the target that failed, maybe even the chain of targets.
+# expect: direct compat
+# expect: *** Error code 1 (continuing)
+# expect: exited 1
+
+# TODO: Add '(continuing)'.
+# expect: direct jobs
+# expect: *** [direct] Error code 1
+# expect: exited 1
+
+# TODO: Mention the target that failed, maybe even the chain of targets.
+# expect: indirect compat
+# expect: *** Error code 1 (continuing)
+# expect: exited 1
+
+# TODO: Add '(continuing)'.
+# expect: indirect jobs
+# expect: *** [direct] Error code 1
+# expect: exited 1