tests/make: document inconsistencies between '!=' and '::!='

Found while trying to make the error messages from Cmd_Exec more
detailed.
This commit is contained in:
rillig 2021-12-28 00:56:16 +00:00
parent 16ba9b01e7
commit 1ed2b64416
4 changed files with 42 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1180 2021/12/23 11:05:58 rillig Exp $
# $NetBSD: mi,v 1.1181 2021/12/28 00:56:16 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -5967,6 +5967,8 @@
./usr/tests/usr.bin/make/unit-tests/varfind.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmisc.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmisc.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign-shell.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign-shell.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-assign.mk tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/make/unit-tests/varmod-defined.exp tests-usr.bin-tests compattestfile,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.291 2021/12/23 11:05:59 rillig Exp $
# $NetBSD: Makefile,v 1.292 2021/12/28 00:56:17 rillig Exp $
#
# Unit tests for make(1)
#
@ -342,6 +342,7 @@ TESTS+= varfind
TESTS+= varmisc
TESTS+= varmod
TESTS+= varmod-assign
TESTS+= varmod-assign-shell
TESTS+= varmod-defined
TESTS+= varmod-edge
TESTS+= varmod-exclam-shell

View File

@ -0,0 +1,5 @@
make: "varmod-assign-shell.mk" line 25: warning: "echo output; false" returned non-zero status
make: "echo output; false" returned non-zero status
DIRECT=output
ASSIGNED=previous
exit status 0

View File

@ -0,0 +1,32 @@
# $NetBSD: varmod-assign-shell.mk,v 1.1 2021/12/28 00:56:17 rillig Exp $
#
# Tests for the variable modifier '::!=', which assigns the output of a shell
# command to the variable, but only if the command exited successfully. This
# is different from the variable assignment operator '!=', which also assigns
# when the shell command fails or crashes.
#
# The variable modifier '::!=' and its close relatives have been around since
# var.c 1.45 from 2000-06-01.
#
# Before 2020.08.25.21.16.53, the variable modifier '::!=' had a bug for
# unsuccessful commands, it put the previous value of the variable into the
# error message instead of the command that was executed. That's where the
# counterintuitive error message 'make: "previous" returned non-zero status'
# comes from.
#
# BUGS
# Even though the variable modifier '::!=' produces an error message,
# the exit status of make is still 0.
#
# Having an error message instead of a warning like for the variable
# assignment operator '!=' is another unnecessary inconsistency.
DIRECT= previous
DIRECT!= echo output; false
ASSIGNED= previous
_:= ${ASSIGNED::!=echo output; false}
all:
@echo DIRECT=${DIRECT:Q}
@echo ASSIGNED=${ASSIGNED:Q}