Module Name: src Committed By: rillig Date: Mon Nov 9 20:39:46 UTC 2020
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile var-op-shell.exp var-op-shell.mk Removed Files: src/usr.bin/make/unit-tests: varshell.exp varshell.mk Log Message: make(1): move test for != assignments to var-op-shell To generate a diff of this commit: cvs rdiff -u -r1.965 -r1.966 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.193 -r1.194 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-op-shell.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-shell.mk cvs rdiff -u -r1.3 -r0 src/usr.bin/make/unit-tests/varshell.exp cvs rdiff -u -r1.4 -r0 src/usr.bin/make/unit-tests/varshell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.965 src/distrib/sets/lists/tests/mi:1.966 --- src/distrib/sets/lists/tests/mi:1.965 Sun Nov 8 23:54:28 2020 +++ src/distrib/sets/lists/tests/mi Mon Nov 9 20:39:46 2020 @@ -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 Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.193 src/usr.bin/make/unit-tests/Makefile:1.194 --- src/usr.bin/make/unit-tests/Makefile:1.193 Mon Nov 9 19:12:52 2020 +++ src/usr.bin/make/unit-tests/Makefile Mon Nov 9 20:39:46 2020 @@ -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-errors 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,Process 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' Index: src/usr.bin/make/unit-tests/var-op-shell.exp diff -u src/usr.bin/make/unit-tests/var-op-shell.exp:1.1 src/usr.bin/make/unit-tests/var-op-shell.exp:1.2 --- src/usr.bin/make/unit-tests/var-op-shell.exp:1.1 Sun Aug 16 12:07:51 2020 +++ src/usr.bin/make/unit-tests/var-op-shell.exp Mon Nov 9 20:39:46 2020 @@ -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 Index: src/usr.bin/make/unit-tests/var-op-shell.mk diff -u src/usr.bin/make/unit-tests/var-op-shell.mk:1.2 src/usr.bin/make/unit-tests/var-op-shell.mk:1.3 --- src/usr.bin/make/unit-tests/var-op-shell.mk:1.2 Sun Aug 16 14:25:16 2020 +++ src/usr.bin/make/unit-tests/var-op-shell.mk Mon Nov 9 20:39:46 2020 @@ -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: - @:;