Thu Oct 29 18:38:24 2020 UTC ()
make(1): add test for ignoring assignment to read-only variable


(rillig)
diff -r1.10 -r1.11 src/usr.bin/make/unit-tests/vardebug.exp
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/vardebug.mk

cvs diff -r1.10 -r1.11 src/usr.bin/make/unit-tests/vardebug.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/vardebug.exp 2020/10/29 18:19:41 1.10
+++ src/usr.bin/make/unit-tests/vardebug.exp 2020/10/29 18:38:24 1.11
@@ -68,18 +68,21 @@ Result of ${:Mvalu[e]} is "value" (VARE_ @@ -68,18 +68,21 @@ Result of ${:Mvalu[e]} is "value" (VARE_
68Var_Parse: ${:UVAR} with VARE_WANTRES 68Var_Parse: ${:UVAR} with VARE_WANTRES
69Applying ${:U...} to "" (VARE_WANTRES, none, VEF_UNDEF) 69Applying ${:U...} to "" (VARE_WANTRES, none, VEF_UNDEF)
70Result of ${:UVAR} is "VAR" (VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 70Result of ${:UVAR} is "VAR" (VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
71Global:delete VAR 71Global:delete VAR
72Var_Parse: ${:Uvariable:unknown} with VARE_UNDEFERR|VARE_WANTRES 72Var_Parse: ${:Uvariable:unknown} with VARE_UNDEFERR|VARE_WANTRES
73Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF) 73Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)
74Result of ${:Uvariable} is "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 74Result of ${:Uvariable} is "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
75Applying ${:u...} to "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 75Applying ${:u...} to "variable" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
76make: Unknown modifier 'u' 76make: Unknown modifier 'u'
77Result of ${:unknown} is error (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF) 77Result of ${:unknown} is error (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF|VEF_DEF)
78make: "vardebug.mk" line 44: Malformed conditional (${:Uvariable:unknown}) 78make: "vardebug.mk" line 44: Malformed conditional (${:Uvariable:unknown})
79Var_Parse: ${UNDEFINED} with VARE_UNDEFERR|VARE_WANTRES 79Var_Parse: ${UNDEFINED} with VARE_UNDEFERR|VARE_WANTRES
80make: "vardebug.mk" line 53: Malformed conditional (${UNDEFINED}) 80make: "vardebug.mk" line 53: Malformed conditional (${UNDEFINED})
 81Global:delete .SHELL (not found)
 82Command:.SHELL = /bin/sh
 83Command:.SHELL = overwritten ignored (read-only)
81Global:.MAKEFLAGS = -r -k -d v -d 84Global:.MAKEFLAGS = -r -k -d v -d
82Global:.MAKEFLAGS = -r -k -d v -d 0 85Global:.MAKEFLAGS = -r -k -d v -d 0
83make: Fatal errors encountered -- cannot continue 86make: Fatal errors encountered -- cannot continue
84make: stopped in unit-tests 87make: stopped in unit-tests
85exit status 1 88exit status 1

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/vardebug.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/vardebug.mk 2020/10/29 18:19:41 1.4
+++ src/usr.bin/make/unit-tests/vardebug.mk 2020/10/29 18:38:24 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $NetBSD: vardebug.mk,v 1.4 2020/10/29 18:19:41 rillig Exp $ 1# $NetBSD: vardebug.mk,v 1.5 2020/10/29 18:38:24 rillig Exp $
2# 2#
3# Demonstrates the debugging output for var.c. 3# Demonstrates the debugging output for var.c.
4 4
5.MAKEFLAGS: -dv FROM_CMDLINE= 5.MAKEFLAGS: -dv FROM_CMDLINE=
6 6
7VAR= added # VarAdd 7VAR= added # VarAdd
8VAR= overwritten # Var_Set 8VAR= overwritten # Var_Set
9.undef VAR # Var_Delete (found) 9.undef VAR # Var_Delete (found)
10.undef VAR # Var_Delete (not found) 10.undef VAR # Var_Delete (not found)
11 11
12# The variable with the empty name cannot be set at all. 12# The variable with the empty name cannot be set at all.
13${:U}= empty name # Var_Set 13${:U}= empty name # Var_Set
14${:U}+= empty name # Var_Append 14${:U}+= empty name # Var_Append
@@ -43,17 +43,22 @@ VAR+= 3 @@ -43,17 +43,22 @@ VAR+= 3
43# as "is error", without surrounding quotes. 43# as "is error", without surrounding quotes.
44.if ${:Uvariable:unknown} 44.if ${:Uvariable:unknown}
45.endif 45.endif
46 46
47# XXX: The error message is "Malformed conditional", which is wrong. 47# XXX: The error message is "Malformed conditional", which is wrong.
48# The condition is syntactically fine, it just contains an undefined variable. 48# The condition is syntactically fine, it just contains an undefined variable.
49# 49#
50# There is a specialized error message for "Undefined variable", but as of 50# There is a specialized error message for "Undefined variable", but as of
51# 2020-08-08, that is not covered by any unit tests. It might even be 51# 2020-08-08, that is not covered by any unit tests. It might even be
52# unreachable. 52# unreachable.
53.if ${UNDEFINED} 53.if ${UNDEFINED}
54.endif 54.endif
55 55
 56# By default, .SHELL is not defined and thus can be set. As soon as it is
 57# accessed, it is initialized in the command line context (during VarFind),
 58# where it is set to read-only. Assigning to it is ignored.
 59.MAKEFLAGS: .SHELL=overwritten
 60
56.MAKEFLAGS: -d0 61.MAKEFLAGS: -d0
57 62
58all: 63all:
59 @: 64 @: