Module Name: src
Committed By: rillig
Date: Fri May 31 07:13:12 UTC 2024
Modified Files:
src/usr.bin/make/unit-tests: directive-for-empty.exp
directive-for-empty.mk opt-debug-hash.exp opt-debug-hash.mk
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for-empty.exp \
src/usr.bin/make/unit-tests/directive-for-empty.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-debug-hash.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-debug-hash.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/directive-for-empty.exp
diff -u src/usr.bin/make/unit-tests/directive-for-empty.exp:1.3 src/usr.bin/make/unit-tests/directive-for-empty.exp:1.4
--- src/usr.bin/make/unit-tests/directive-for-empty.exp:1.3 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/directive-for-empty.exp Fri May 31 07:13:12 2024
@@ -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
Index: src/usr.bin/make/unit-tests/directive-for-empty.mk
diff -u src/usr.bin/make/unit-tests/directive-for-empty.mk:1.3 src/usr.bin/make/unit-tests/directive-for-empty.mk:1.4
--- src/usr.bin/make/unit-tests/directive-for-empty.mk:1.3 Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/directive-for-empty.mk Fri May 31 07:13:12 2024
@@ -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
+. 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:no
# TODO: Add code that demonstrates the current interaction between variables
# from .for loops and the modifiers mentioned above.
+
+all:
Index: src/usr.bin/make/unit-tests/opt-debug-hash.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.5 src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.6
--- src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.5 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/opt-debug-hash.exp Fri May 31 07:13:12 2024
@@ -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
Index: src/usr.bin/make/unit-tests/opt-debug-hash.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.4 src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.5
--- src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.4 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/opt-debug-hash.mk Fri May 31 07:13:12 2024
@@ -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