Module Name:    src
Committed By:   rillig
Date:           Wed Dec  9 00:43:48 UTC 2020

Modified Files:
        src/usr.bin/make/unit-tests: opt-jobs-no-action.exp
            opt-jobs-no-action.mk

Log Message:
make(1): add more tests for combining -j1 and -n


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/opt-jobs-no-action.exp \
    src/usr.bin/make/unit-tests/opt-jobs-no-action.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/opt-jobs-no-action.exp
diff -u src/usr.bin/make/unit-tests/opt-jobs-no-action.exp:1.1 src/usr.bin/make/unit-tests/opt-jobs-no-action.exp:1.2
--- src/usr.bin/make/unit-tests/opt-jobs-no-action.exp:1.1	Wed Dec  9 00:25:00 2020
+++ src/usr.bin/make/unit-tests/opt-jobs-no-action.exp	Wed Dec  9 00:43:48 2020
@@ -12,4 +12,64 @@ echo "false regular"
 false ignore-errors
 echo run despite the -n option
 run despite the -n option
+echo
+
+echo 'begin combined'
+begin combined
+echo
+
+echo silent=no always=no ignerr=no
+silent=no always=no ignerr=no
+# .echoOff
+# .errOnOrEcho
+echo "true"
+# .errExit
+{ true 
+} || exit $?
+# .echoOn
+echo
+
+echo silent=no always=no ignerr=yes
+silent=no always=no ignerr=yes
+false
+echo
+
+echo silent=no always=yes ignerr=no
+silent=no always=yes ignerr=no
+true
+echo
+
+echo silent=no always=yes ignerr=yes
+silent=no always=yes ignerr=yes
+false
+*** Error code 1 (ignored)
+echo
+
+echo silent=yes always=no ignerr=no
+silent=yes always=no ignerr=no
+# .errExit
+{ true 
+} || exit $?
+# .echoOn
+echo
+
+echo silent=yes always=no ignerr=yes
+silent=yes always=no ignerr=yes
+false
+# .echoOn
+echo
+
+echo silent=yes always=yes ignerr=no
+silent=yes always=yes ignerr=no
+true
+echo
+
+echo silent=yes always=yes ignerr=yes
+silent=yes always=yes ignerr=yes
+false
+*** Error code 1 (ignored)
+echo
+
+echo 'end combined'
+end combined
 exit status 0
Index: src/usr.bin/make/unit-tests/opt-jobs-no-action.mk
diff -u src/usr.bin/make/unit-tests/opt-jobs-no-action.mk:1.1 src/usr.bin/make/unit-tests/opt-jobs-no-action.mk:1.2
--- src/usr.bin/make/unit-tests/opt-jobs-no-action.mk:1.1	Wed Dec  9 00:25:00 2020
+++ src/usr.bin/make/unit-tests/opt-jobs-no-action.mk	Wed Dec  9 00:43:48 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-jobs-no-action.mk,v 1.1 2020/12/09 00:25:00 rillig Exp $
+# $NetBSD: opt-jobs-no-action.mk,v 1.2 2020/12/09 00:43:48 rillig Exp $
 #
 # Tests for the combination of the options -j and -n, which prints the
 # commands instead of actually running them.
@@ -6,6 +6,8 @@
 # The format of the output differs from the output of only the -n option,
 # without the -j.  This is because all this code is implemented twice, once
 # in compat.c and once in job.c.
+#
+# See opt-jobs.mk for the corresponding tests without the -n option.
 
 .MAKEFLAGS: -j1 -n
 
@@ -28,7 +30,18 @@
 	ignore="\# .errOffOrExecIgnore\n""%s\n" \
 	errout="\# .errExit\n""{ %s \n} || exit $$?\n"
 
-all:
+SILENT.no=	# none
+SILENT.yes=	@
+ALWAYS.no=	# none
+ALWAYS.yes=	+
+IGNERR.no=	true
+IGNERR.yes=	-false
+
+all: documented combined
+.ORDER: documented combined
+
+# Explain the most basic cases in detail.
+documented: .PHONY
 	# The following command is regular, it is printed twice:
 	# - first using the template shell.errOnOrEcho,
 	# - then using the template shell.errExit.
@@ -49,7 +62,22 @@ all:
 	# '!silent' in Compat_RunCommand.
 	+echo run despite the -n option
 
-	# TODO: test all 8 combinations of '-', '+', '@'.
-	# TODO: for each of the above test, test '-true' and '-false'.
-	# The code with its many branches feels like a big mess.
-	# See opt-jobs.mk for the corresponding tests without the -n option.
+	@+echo
+
+# Test all combinations of the 3 RunFlags.
+#
+# TODO: Closely inspect the output whether it makes sense.
+# XXX: The output should not contain the 'echo silent=...' lines.
+combined:
+	@+echo 'begin $@'
+	@+echo
+.for silent in no yes
+.  for always in no yes
+.    for ignerr in no yes
+	@+echo silent=${silent} always=${always} ignerr=${ignerr}
+	${SILENT.${silent}}${ALWAYS.${always}}${IGNERR.${ignerr}}
+	@+echo
+.    endfor
+.  endfor
+.endfor
+	@+echo 'end $@'

Reply via email to