summaryrefslogtreecommitdiff
path: root/usr.bin/make/unit-tests
diff options
context:
space:
mode:
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