Module Name:    src
Committed By:   rillig
Date:           Sun Aug 23 09:18:26 UTC 2020

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/usr.bin/make/unit-tests: Makefile
Added Files:
        src/usr.bin/make/unit-tests: varname-dot-shell.exp varname-dot-shell.mk

Log Message:
make(1): add test for the newly added .SHELL variable


To generate a diff of this commit:
cvs rdiff -u -r1.901 -r1.902 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-dot-shell.exp \
    src/usr.bin/make/unit-tests/varname-dot-shell.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.901 src/distrib/sets/lists/tests/mi:1.902
--- src/distrib/sets/lists/tests/mi:1.901	Sat Aug 22 21:55:54 2020
+++ src/distrib/sets/lists/tests/mi	Sun Aug 23 09:18:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.901 2020/08/22 21:55:54 rillig Exp $
+# $NetBSD: mi,v 1.902 2020/08/23 09:18:25 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5051,6 +5051,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-parsefile.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-path.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-path.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dot-shell.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-dot-shell.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-empty.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.114 src/usr.bin/make/unit-tests/Makefile:1.115
--- src/usr.bin/make/unit-tests/Makefile:1.114	Sat Aug 22 21:55:54 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Aug 23 09:18:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.114 2020/08/22 21:55:54 rillig Exp $
+# $NetBSD: Makefile,v 1.115 2020/08/23 09:18:25 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -293,6 +293,7 @@ TESTS+=		varname-dot-objdir
 TESTS+=		varname-dot-parsedir
 TESTS+=		varname-dot-parsefile
 TESTS+=		varname-dot-path
+TESTS+=		varname-dot-shell
 TESTS+=		varname-dot-targets
 TESTS+=		varname-empty
 TESTS+=		varname-make
@@ -324,6 +325,7 @@ FLAGS.order=		-j1
 FLAGS.recursive=	-dL
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 FLAGS.varmod-match-escape= -dv
+FLAGS.varname-dot-shell= -dpv
 FLAGS.varname-empty=	-dv '$${:U}=cmdline-u' '=cmline-plain'
 
 # Some tests need extra post-processing.
@@ -333,11 +335,14 @@ SED_CMDS.varmod-subst-regex+= \
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
 SED_CMDS.varshell+=	-e 's,^${.SHELL:T}: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'
+SED_CMDS.varname-dot-shell= -e 's, = /.*, = (details omitted),'
 
 # Some tests need an additional round of postprocessing.
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
+POSTPROC.varname-dot-shell= \
+			awk '/\.SHELL/ || /^ParseReadLine/'
 POSTPROC.varname-empty=	${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
 
 # Some tests reuse other tests, which makes them unnecessarily fragile.

Added files:

Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.1
--- /dev/null	Sun Aug 23 09:18:26 2020
+++ src/usr.bin/make/unit-tests/varname-dot-shell.exp	Sun Aug 23 09:18:25 2020
@@ -0,0 +1,14 @@
+ParseReadLine (8): 'ORIG_SHELL:=	${.SHELL}'
+Var_Parse: ${.SHELL} with VARE_WANTRES|VARE_ASSIGN
+Global:delete .SHELL (not found)
+Command:.SHELL = (details omitted)
+ParseReadLine (10): '.SHELL=		overwritten'
+Global:.SHELL = overwritten
+Var_Parse: ${.SHELL} != ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+ParseReadLine (18): '.undef .SHELL'
+Global:delete .SHELL
+ParseReadLine (19): '.SHELL=		newly overwritten'
+Global:.SHELL = newly overwritten
+Var_Parse: ${.SHELL} != ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
+ParseReadLine (24): 'all:'
+exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-shell.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varname-dot-shell.mk:1.1
--- /dev/null	Sun Aug 23 09:18:26 2020
+++ src/usr.bin/make/unit-tests/varname-dot-shell.mk	Sun Aug 23 09:18:25 2020
@@ -0,0 +1,26 @@
+# $NetBSD: varname-dot-shell.mk,v 1.1 2020/08/23 09:18:25 rillig Exp $
+#
+# Tests for the special .SHELL variable, which contains the shell used for
+# running the commands.
+#
+# This variable is read-only.
+
+ORIG_SHELL:=	${.SHELL}
+
+.SHELL=		overwritten
+.if ${.SHELL} != ${ORIG_SHELL}
+.error
+.endif
+
+# Trying to delete the variable.
+# This has no effect since the variable is not defined in the global context,
+# but in the command-line context.
+.undef .SHELL
+.SHELL=		newly overwritten
+.if ${.SHELL} != ${ORIG_SHELL}
+.error
+.endif
+
+all:
+# Cannot be activated yet because VAR_READONLY is not in the debug info.
+#	@echo ${.SHELL:M*}

Reply via email to