tests/make: replace or document .error in tests

The text 'Missing argument for ".error"' in an .exp file may be a hint
for an accidentally broken test, so eliminate them as far as possible.
This commit is contained in:
rillig 2024-05-31 07:13:12 +00:00
parent 72b6692e9f
commit 0fbf3fce65
4 changed files with 20 additions and 22 deletions

View File

@ -1,7 +1,4 @@
make: "directive-for-empty.mk" line 22: 2
make: "directive-for-empty.mk" line 38: Missing argument for ".error"
make: "directive-for-empty.mk" line 38: Missing argument for ".error"
make: "directive-for-empty.mk" line 38: Missing argument for ".error"
For: end for 1
For: loop body with i = value:
# The identifier 'empty' can only be used in conditions such as .if, .ifdef or
@ -22,6 +19,4 @@ CPPFLAGS+= -Dmessage="empty(i)"
# condition directives, they can also occur in the modifier ':?', see
# varmod-ifelse.mk.
CPPFLAGS+= -Dmacro="${empty(i):?empty:not-empty}"
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
exit status 0

View File

@ -1,4 +1,4 @@
# $NetBSD: directive-for-empty.mk,v 1.3 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: directive-for-empty.mk,v 1.4 2024/05/31 07:13:12 rillig Exp $
#
# Tests for .for loops containing conditions of the form 'empty(var:...)'.
#
@ -26,23 +26,23 @@
# In conditions, the function call to 'empty' does not look like an
# expression, therefore it is not replaced. Since there is no global variable
# named 'i', this expression makes for a leaky abstraction. If the .for
# named 'i', this condition makes for a leaky abstraction. If the .for
# variables were real variables, calling 'empty' would work on them as well.
.for i in 11 12 13
# Asking for an empty iteration variable does not make sense as the .for loop
# splits the iteration items into words, and such a word cannot be empty.
. if empty(i)
# expect+3: Missing argument for ".error"
# expect+2: Missing argument for ".error"
# expect+1: Missing argument for ".error"
. error # due to the leaky abstraction
. if !empty(i)
. error # not reached, due to the leaky abstraction
. endif
# The typical way of using 'empty' with variables from .for loops is pattern
# matching using the modifiers ':M' or ':N'.
# The typical way of mistakenly using 'empty' with variables from .for loops
# is pattern matching using the modifiers ':M' or ':N'.
. if !empty(i:M*2*)
. if ${i} != "12"
. error
. endif
# Instead of the 'empty' function, the variables from .for loops can be
# queried using conditions of the form '${var:...} != ""'.
. if $i == "12" && ${i:M*2*} != "12"
. error
. endif
.endfor
@ -122,3 +122,5 @@ CPPFLAGS+= -Dmacro="${empty(i):?empty:not-empty}"
# TODO: Add code that demonstrates the current interaction between variables
# from .for loops and the modifiers mentioned above.
all:

View File

@ -1,4 +1,4 @@
make: "opt-debug-hash.mk" line 12: Missing argument for ".error"
make: "opt-debug-hash.mk" line 13: Missing argument for ".error"
make: Fatal errors encountered -- cannot continue
HashTable targets: size=16 numEntries=0 maxchain=0
HashTable Global variables: size=16 numEntries=<entries> maxchain=3

View File

@ -1,4 +1,4 @@
# $NetBSD: opt-debug-hash.mk,v 1.4 2023/06/01 20:56:35 rillig Exp $
# $NetBSD: opt-debug-hash.mk,v 1.5 2024/05/31 07:13:12 rillig Exp $
#
# Tests for the -dh command line option, which adds debug logging for
# hash tables. Even more detailed logging is available by compiling
@ -6,7 +6,8 @@
.MAKEFLAGS: -dh
# Force a parse error, to demonstrate the newline character in the diagnostic
# that had been missing before parse.c 1.655 from 2022-01-22.
# Force a parse error, to demonstrate the newline character in the "cannot
# continue" diagnostic that had been missing before parse.c 1.655 from
# 2022-01-22.
# expect+1: Missing argument for ".error"
.error