summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2021-04-27 16:20:06 +0000
committerrillig <rillig@NetBSD.org>2021-04-27 16:20:06 +0000
commitb756cc91c8a5bfcb72d49b3ee1bd0702843f7df8 (patch)
tree3bb5ad621f7bf28bc3e073f4a260410a7664ef8f /usr.bin/make/unit-tests
parent09d76c9e4a9d37e690bfd4404daeda66fbe7879a (diff)
tests/make: test the combination of -de with -j1
The test cases are the same as in opt-debug-errors.mk. The output differs in several details though. Even though the option '-k' is given (which is the default for any tests that don't override it in unit-tests/Makefile), there is no message "(continuing)" anywhere. The failed target is printed twice. Once before the failed commands, once after. This redundancy is not necessary and may be removed in a follow-up commit. The printed commands are in their unexpanded form, which may or may not be more helpful than the expanded and space-normalized form of compat mode. Either way, this is an unnecessary inconsistency between compat mode and jobs mode. In jobs mode, the message "make: stopped in $dir" is printed for each failure, which is helpful since each of the jobs may have started in a separate directory.
Diffstat (limited to 'usr.bin/make/unit-tests')
-rw-r--r--usr.bin/make/unit-tests/Makefile3
-rw-r--r--usr.bin/make/unit-tests/opt-debug-errors-jobs.exp48
-rw-r--r--usr.bin/make/unit-tests/opt-debug-errors-jobs.mk36
3 files changed, 86 insertions, 1 deletions
diff --git a/usr.bin/make/unit-tests/Makefile b/usr.bin/make/unit-tests/Makefile
index 21991a6531c..22afac9d567 100644
--- a/usr.bin/make/unit-tests/Makefile
+++ b/usr.bin/make/unit-tests/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.276 2021/04/15 19:02:29 rillig Exp $
+# $NetBSD: Makefile,v 1.277 2021/04/27 16:20:06 rillig Exp $
#
# Unit tests for make(1)
#
@@ -230,6 +230,7 @@ TESTS+= opt-debug-curdir
TESTS+= opt-debug-cond
TESTS+= opt-debug-dir
TESTS+= opt-debug-errors
+TESTS+= opt-debug-errors-jobs
TESTS+= opt-debug-file
TESTS+= opt-debug-for
TESTS+= opt-debug-graph1
diff --git a/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp b/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp
new file mode 100644
index 00000000000..c4cffbc7a23
--- /dev/null
+++ b/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp
@@ -0,0 +1,48 @@
+echo '3 spaces'; false
+3 spaces
+
+*** Failed target: fail-spaces
+*** Failed commands:
+ echo '3 spaces'; false
+*** [fail-spaces] Error code 1
+
+make: stopped in unit-tests
+echo \ indented; false
+ indented
+
+*** Failed target: fail-escaped-space
+*** Failed commands:
+ echo \ indented; false
+*** [fail-escaped-space] Error code 1
+
+make: stopped in unit-tests
+echo 'line1
+line2'; false
+line1
+line2
+
+*** Failed target: fail-newline
+*** Failed commands:
+ echo 'line1${.newline}line2'; false
+*** [fail-newline] Error code 1
+
+make: stopped in unit-tests
+echo 'line1 line2'; false
+line1 line2
+
+*** Failed target: fail-multiline
+*** Failed commands:
+ echo 'line1 line2'; false
+*** [fail-multiline] Error code 1
+
+make: stopped in unit-tests
+echo 'word1' 'word2'; false
+word1 word2
+
+*** Failed target: fail-multiline-intention
+*** Failed commands:
+ echo 'word1' 'word2'; false
+*** [fail-multiline-intention] Error code 1
+
+make: stopped in unit-tests
+exit status 1
diff --git a/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk b/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk
new file mode 100644
index 00000000000..83b50987a75
--- /dev/null
+++ b/usr.bin/make/unit-tests/opt-debug-errors-jobs.mk
@@ -0,0 +1,36 @@
+# $NetBSD: opt-debug-errors-jobs.mk,v 1.1 2021/04/27 16:20:06 rillig Exp $
+#
+# Tests for the -de command line option, which adds debug logging for
+# failed commands and targets; since 2021-04-27 also in jobs mode.
+
+.MAKEFLAGS: -de -j1
+
+all: fail-spaces
+all: fail-escaped-space
+all: fail-newline
+all: fail-multiline
+all: fail-multiline-intention
+
+fail-spaces:
+ echo '3 spaces'; false
+
+fail-escaped-space:
+ echo \ indented; false
+
+fail-newline:
+ echo 'line1${.newline}line2'; false
+
+# The line continuations in multiline commands are turned into an ordinary
+# space before the command is actually run.
+fail-multiline:
+ echo 'line1\
+ line2'; false
+
+# It is a common style to align the continuation backslashes at the right
+# of the lines, usually at column 73. All spaces before the continuation
+# backslash are preserved and are usually outside a shell word and thus
+# irrelevant. Since "usually" is not "always", these space characters are
+# not merged into a single space.
+fail-multiline-intention:
+ echo 'word1' \
+ 'word2'; false