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): move test for != assignment...



details:   https://anonhg.NetBSD.org/src/rev/cb7907142aec
branches:  trunk
changeset: 956901:cb7907142aec
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Nov 09 20:39:46 2020 +0000

description:
make(1): move test for != assignments to var-op-shell

diffstat:

 distrib/sets/lists/tests/mi              |   6 +-
 usr.bin/make/unit-tests/Makefile         |   9 +-
 usr.bin/make/unit-tests/var-op-shell.exp |   6 ++
 usr.bin/make/unit-tests/var-op-shell.mk  |  81 ++++++++++++++++++++++++++++++-
 usr.bin/make/unit-tests/varshell.exp     |  12 ----
 usr.bin/make/unit-tests/varshell.mk      |  18 -------
 6 files changed, 91 insertions(+), 41 deletions(-)

diffs (201 lines):

diff -r 01066e3d0c35 -r cb7907142aec distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Mon Nov 09 20:16:33 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Mon Nov 09 20:39:46 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.965 2020/11/08 23:54:28 rillig Exp $
+# $NetBSD: mi,v 1.966 2020/11/09 20:39:46 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5511,8 +5511,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varparse-undef-partial.mk                  tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varquote.exp                               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varquote.mk                                        tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/varshell.exp                               tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/varshell.mk                                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varshell.exp                               tests-obsolete          obsolete
+./usr/tests/usr.bin/make/unit-tests/varshell.mk                                        tests-obsolete          obsolete
 ./usr/tests/usr.bin/mixerctl                           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/mixerctl/Atffile                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/mixerctl/Kyuafile                  tests-usr.bin-tests     compattestfile,atf,kyua
diff -r 01066e3d0c35 -r cb7907142aec usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Mon Nov 09 20:16:33 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Mon Nov 09 20:39:46 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.193 2020/11/09 19:12:52 sjg Exp $
+# $NetBSD: Makefile,v 1.194 2020/11/09 20:39:46 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -377,16 +377,15 @@
 TESTS+=                varparse-mod
 TESTS+=                varparse-undef-partial
 TESTS+=                varquote
-TESTS+=                varshell
 
 # Additional environment variables for some of the tests.
 # The base environment is -i PATH="$PATH".
+ENV.depsrc-optional+=   TZ=UTC
 ENV.envfirst=          FROM_ENV=value-from-env
 ENV.varmisc=           FROM_ENV=env
 ENV.varmisc+=          FROM_ENV_BEFORE=env
 ENV.varmisc+=          FROM_ENV_AFTER=env
 ENV.varmod-localtime+= TZ=Europe/Berlin
-ENV.depsrc-optional+=   TZ=UTC
 
 # Override make flags for some of the tests; default is -k.
 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
@@ -431,11 +430,11 @@
 SED_CMDS.opt-debug-jobs+=      -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
 # The "-q" may be there or not, see jobs.c, variable shells.
 SED_CMDS.opt-debug-jobs+=      -e 's,^\(.Command: sh\) -q,\1,'
+SED_CMDS.var-op-shell+=        -e 's,^${.SHELL:T}: ,,'
+SED_CMDS.var-op-shell+=        -e '/command/s,No such.*,not found,'
 SED_CMDS.varmod-subst-regex+= \
                        -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varmod-edge+= -e 's, line [0-9]*:, line omitted:,'
-SED_CMDS.varshell+=    -e 's,^${.SHELL:T}: ,,'
-SED_CMDS.varshell+=    -e '/command/s,No such.*,not found,'
 SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
 SED_CMDS.varname-dot-parsefile=        -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
 SED_CMDS.varname-dot-shell=    -e 's, = /[^ ]*, = (details omitted),g'
diff -r 01066e3d0c35 -r cb7907142aec usr.bin/make/unit-tests/var-op-shell.exp
--- a/usr.bin/make/unit-tests/var-op-shell.exp  Mon Nov 09 20:16:33 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-shell.exp  Mon Nov 09 20:39:46 2020 +0000
@@ -1,1 +1,7 @@
+make: "var-op-shell.mk" line 28: warning: "echo "failed"; false" returned non-zero status
+make: "var-op-shell.mk" line 34: warning: "false" returned non-zero status
+make: "var-op-shell.mk" line 59: warning: "kill -14 $$" exited on a signal
+/bin/no/such/command: not found
+make: "var-op-shell.mk" line 65: warning: "/bin/no/such/command" returned non-zero status
+stderr
 exit status 0
diff -r 01066e3d0c35 -r cb7907142aec usr.bin/make/unit-tests/var-op-shell.mk
--- a/usr.bin/make/unit-tests/var-op-shell.mk   Mon Nov 09 20:16:33 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-shell.mk   Mon Nov 09 20:39:46 2020 +0000
@@ -1,9 +1,84 @@
-# $NetBSD: var-op-shell.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: var-op-shell.mk,v 1.3 2020/11/09 20:39:46 rillig Exp $
 #
 # Tests for the != variable assignment operator, which runs its right-hand
 # side through the shell.
 
-# TODO: Implementation
+# The variable OUTPUT gets the output from running the shell command.
+OUTPUT!=       echo "success"'ful'
+.if ${OUTPUT} != "successful"
+.  error
+.endif
+
+# Since 2014-08-20, the output of the shell command may be empty.
+#
+# On 1996-05-29, when the '!=' assignment operator and Cmd_Exec were added,
+# an empty output produced the error message "Couldn't read shell's output
+# for \"%s\"".
+#
+# The error message is still there but reserved for technical errors.
+# It may be possible to trigger the error message by killing the shell after
+# reading part of its output.
+OUTPUT!=       true
+.if ${OUTPUT} != ""
+.  error
+.endif
+
+# The output of a shell command that failed is processed nevertheless.
+# TODO: Make this an error in lint mode.
+OUTPUT!=       echo "failed"; false
+.if ${OUTPUT} != "failed"
+.  error
+.endif
+
+# A command with empty output may fail as well.
+OUTPUT!=       false
+.if ${OUTPUT} != ""
+.  error
+.endif
+
+# In the output of the command, each newline is replaced with a space.
+# Except for the very last one, which is discarded.
+OUTPUT!=       echo "line 1"; echo "line 2"
+.if ${OUTPUT} != "line 1 line 2"
+.  error
+.endif
+
+# A failing command in the middle results in the exit status 0, which in the
+# end means that the whole sequence of commands succeeded.
+OUTPUT!=       echo "before"; false; echo "after"
+.if ${OUTPUT} != "before after"
+.  error
+.endif
+
+# NB: The signal number must be numeric since some shells (which ones?) don't
+# accept symbolic signal names.  14 is typically SIGALRM.
+#
+# XXX: The number of the signal is not mentioned in the warning since that
+# would have been difficult to implement; currently the errfmt is a format
+# string containing a single %s conversion.
+OUTPUT!=       kill -14 $$$$
+.if ${OUTPUT} != ""
+.  error
+.endif
+
+# A nonexistent command produces a non-zero exit status.
+OUTPUT!=       /bin/no/such/command
+.if ${OUTPUT} != ""
+.  error
+.endif
+
+# The output from the shell's stderr is not captured, it just passes through.
+OUTPUT!=       echo "stdout"; echo "stderr" 1>&2
+.if ${OUTPUT} != "stdout"
+.  error
+.endif
+
+# The 8 dollar signs end up as 4 dollar signs when expanded.  The shell sees
+# the command "echo '$$$$'".  The 4 dollar signs are stored in OUTPUT, and
+# when that variable is expanded, they expand to 2 dollar signs.
+OUTPUT!=       echo '$$$$$$$$'
+.if ${OUTPUT} != "\$\$"
+.  error
+.endif
 
 all:
-       @:;
diff -r 01066e3d0c35 -r cb7907142aec usr.bin/make/unit-tests/varshell.exp
--- a/usr.bin/make/unit-tests/varshell.exp      Mon Nov 09 20:16:33 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-/bin/no/such/command: not found
-make: "varshell.mk" line 5: warning: "/bin/no/such/command" returned non-zero status
-make: "varshell.mk" line 6: warning: "kill -14 $$" exited on a signal
-make: "varshell.mk" line 7: warning: "false" returned non-zero status
-make: "varshell.mk" line 8: warning: "echo "output before the error"; false" returned non-zero status
-EXEC_FAILED=''
-TERMINATED_BY_SIGNAL=''
-ERROR_NO_OUTPUT=''
-ERROR_WITH_OUTPUT='output before the error'
-NO_ERROR_NO_OUTPUT=''
-NO_ERROR_WITH_OUTPUT='this is good'
-exit status 0
diff -r 01066e3d0c35 -r cb7907142aec usr.bin/make/unit-tests/varshell.mk
--- a/usr.bin/make/unit-tests/varshell.mk       Mon Nov 09 20:16:33 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,18 +0,0 @@
-# $NetBSD: varshell.mk,v 1.4 2020/10/24 08:50:17 rillig Exp $
-#
-# Test VAR != shell command
-
-EXEC_FAILED!=          /bin/no/such/command
-TERMINATED_BY_SIGNAL!= kill -14 $$$$
-ERROR_NO_OUTPUT!=      false
-ERROR_WITH_OUTPUT!=    echo "output before the error"; false
-NO_ERROR_NO_OUTPUT!=   true
-NO_ERROR_WITH_OUTPUT!= echo "this is good"
-
-allvars=       EXEC_FAILED TERMINATED_BY_SIGNAL ERROR_NO_OUTPUT ERROR_WITH_OUTPUT \
-               NO_ERROR_NO_OUTPUT NO_ERROR_WITH_OUTPUT
-
-all:
-.for v in ${allvars}
-       @echo ${v}=\'${${v}}\'
-.endfor



Home | Main Index | Thread Index | Old Index