Mon Sep 14 21:52:49 2020 UTC ()
make(1): add test for wrong error in lint mode for undefined variable


(rillig)
diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-debug-lint.mk

cvs diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-debug-lint.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-debug-lint.exp 2020/09/14 07:13:29 1.5
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp 2020/09/14 21:52:49 1.6
@@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
1make: "opt-debug-lint.mk" line 19: Variable "X" is undefined 1make: "opt-debug-lint.mk" line 19: Variable "X" is undefined
2make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined 2make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined
 3make: "opt-debug-lint.mk" line 58: Variable "UNDEF" is undefined
3make: Fatal errors encountered -- cannot continue 4make: Fatal errors encountered -- cannot continue
4make: stopped in unit-tests 5make: stopped in unit-tests
5exit status 1 6exit status 1

cvs diff -r1.5 -r1.6 src/usr.bin/make/unit-tests/opt-debug-lint.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-debug-lint.mk 2020/09/14 21:23:58 1.5
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk 2020/09/14 21:52:49 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: opt-debug-lint.mk,v 1.5 2020/09/14 21:23:58 rillig Exp $ 1# $NetBSD: opt-debug-lint.mk,v 1.6 2020/09/14 21:52:49 rillig Exp $
2# 2#
3# Tests for the -dL command line option, which runs additional checks 3# Tests for the -dL command line option, which runs additional checks
4# to catch common mistakes, such as unclosed variable expressions. 4# to catch common mistakes, such as unclosed variable expressions.
5  5
6.MAKEFLAGS: -dL 6.MAKEFLAGS: -dL
7 7
8# Since 2020-09-13, undefined variables that are used on the left-hand side 8# Since 2020-09-13, undefined variables that are used on the left-hand side
9# of a condition at parse time get a proper error message. Before, the 9# of a condition at parse time get a proper error message. Before, the
10# error message was "Malformed conditional" only, which was wrong and 10# error message was "Malformed conditional" only, which was wrong and
11# misleading. The form of the condition is totally fine, it's the evaluation 11# misleading. The form of the condition is totally fine, it's the evaluation
12# that fails. 12# that fails.
13# 13#
14# Since 2020-09-13, the "Malformed conditional" error message is not printed 14# Since 2020-09-13, the "Malformed conditional" error message is not printed
@@ -37,15 +37,27 @@ @@ -37,15 +37,27 @@
37# but only in lint mode. Before, it had only silently returned var_Error, 37# but only in lint mode. Before, it had only silently returned var_Error,
38# hoping for the caller to print an error message. This resulted in the 38# hoping for the caller to print an error message. This resulted in the
39# well-known "Malformed conditional" error message, even though the 39# well-known "Malformed conditional" error message, even though the
40# conditional was well-formed and the only error was an undefined variable. 40# conditional was well-formed and the only error was an undefined variable.
41.if ${UNDEF} 41.if ${UNDEF}
42. error 42. error
43.endif 43.endif
44 44
45# Since 2020-09-14, dependency lines may contain undefined variables. 45# Since 2020-09-14, dependency lines may contain undefined variables.
46# Before, undefined variables were forbidden, but this distinction was not 46# Before, undefined variables were forbidden, but this distinction was not
47# observable from the outside of the function Var_Parse. 47# observable from the outside of the function Var_Parse.
48${UNDEF}: ${UNDEF} 48${UNDEF}: ${UNDEF}
49 49
 50# In a condition that has a defined(UNDEF) guard, all guarded conditions
 51# may assume that the variable is defined since they will only be evaluated
 52# if the variable is indeed defined. Otherwise they are only parsed, and
 53# for parsing it doesn't make a difference whether the variable is defined
 54# or not.
 55#
 56# FIXME: As of 2020-09-14, the following line prints an error message saying
 57# that UNDEF is undefined.
 58.if defined(UNDEF) && exists(${UNDEF})
 59. error
 60.endif
 61
50all: 62all:
51 @:; 63 @:;