Module Name: src
Committed By: rillig
Date: Fri Dec 11 01:06:10 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: sh-jobs.exp sh-jobs.mk
Log Message:
make(1): add tests for comments and non-comments in jobs mode
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/sh-jobs.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/sh-jobs.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/sh-jobs.exp
diff -u src/usr.bin/make/unit-tests/sh-jobs.exp:1.1 src/usr.bin/make/unit-tests/sh-jobs.exp:1.2
--- src/usr.bin/make/unit-tests/sh-jobs.exp:1.1 Sun Aug 16 12:07:51 2020
+++ src/usr.bin/make/unit-tests/sh-jobs.exp Fri Dec 11 01:06:10 2020
@@ -1 +1,6 @@
-exit status 0
+comment-with-followup-line: This is printed.
+no-comment: This is printed.
+*** [no-comment] Error code 1
+
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/sh-jobs.mk
diff -u src/usr.bin/make/unit-tests/sh-jobs.mk:1.2 src/usr.bin/make/unit-tests/sh-jobs.mk:1.3
--- src/usr.bin/make/unit-tests/sh-jobs.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/sh-jobs.mk Fri Dec 11 01:06:10 2020
@@ -1,9 +1,35 @@
-# $NetBSD: sh-jobs.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: sh-jobs.mk,v 1.3 2020/12/11 01:06:10 rillig Exp $
#
# Tests for the "run in jobs mode" part of the "Shell Commands" section
# from the manual page.
-# TODO: Implementation
+# TODO: Tutorial
-all:
- @:;
+.MAKEFLAGS: -j1
+
+all: .PHONY comment .WAIT comment-with-followup-line .WAIT no-comment
+
+# If a shell command starts with a comment character after stripping the
+# leading '@', it is run in ignore-errors mode since the default runChkTmpl
+# would lead to a syntax error in the generated shell file, at least for
+# bash and dash, but not for NetBSD sh and ksh.
+#
+# See JobPrintCommand, cmdTemplate, runIgnTmpl
+comment: .PHONY
+ @# comment
+
+# If a shell command starts with a comment character after stripping the
+# leading '@', it is run in ignore-errors mode.
+#
+# See JobPrintCommand, cmdTemplate, runIgnTmpl
+comment-with-followup-line: .PHONY
+ @# comment${.newline}echo '$@: This is printed.'; false
+ @true
+
+# Without the comment, the commands are run in the default mode, which checks
+# the exit status of every makefile line.
+#
+# See JobPrintCommand, cmdTemplate, runChkTmpl
+no-comment: .PHONY
+ @echo '$@: This is printed.'; false
+ @true