Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add more tests for combinin...



details:   https://anonhg.NetBSD.org/src/rev/87688446e8f2
branches:  trunk
changeset: 1016988:87688446e8f2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 09 00:43:48 2020 +0000

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

diffstat:

 usr.bin/make/unit-tests/opt-jobs-no-action.exp |  60 ++++++++++++++++++++++++++
 usr.bin/make/unit-tests/opt-jobs-no-action.mk  |  40 ++++++++++++++--
 2 files changed, 94 insertions(+), 6 deletions(-)

diffs (133 lines):

diff -r 1ac6685e9b32 -r 87688446e8f2 usr.bin/make/unit-tests/opt-jobs-no-action.exp
--- a/usr.bin/make/unit-tests/opt-jobs-no-action.exp    Wed Dec 09 00:25:00 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-jobs-no-action.exp    Wed Dec 09 00:43:48 2020 +0000
@@ -12,4 +12,64 @@
 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
diff -r 1ac6685e9b32 -r 87688446e8f2 usr.bin/make/unit-tests/opt-jobs-no-action.mk
--- a/usr.bin/make/unit-tests/opt-jobs-no-action.mk     Wed Dec 09 00:25:00 2020 +0000
+++ b/usr.bin/make/unit-tests/opt-jobs-no-action.mk     Wed Dec 09 00:43:48 2020 +0000
@@ -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 @@
        # '!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 $@'



Home | Main Index | Thread Index | Old Index