Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests make(1): add test for the newly adde...



details:   https://anonhg.NetBSD.org/src/rev/b4b0aca632d4
branches:  trunk
changeset: 937665:b4b0aca632d4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 23 09:18:25 2020 +0000

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

diffstat:

 distrib/sets/lists/tests/mi                   |   4 +++-
 usr.bin/make/unit-tests/Makefile              |   7 ++++++-
 usr.bin/make/unit-tests/varname-dot-shell.exp |  14 ++++++++++++++
 usr.bin/make/unit-tests/varname-dot-shell.mk  |  26 ++++++++++++++++++++++++++
 4 files changed, 49 insertions(+), 2 deletions(-)

diffs (106 lines):

diff -r 8140e8fcfa50 -r b4b0aca632d4 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Aug 23 08:32:57 2020 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Aug 23 09:18:25 2020 +0000
@@ -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
diff -r 8140e8fcfa50 -r b4b0aca632d4 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile  Sun Aug 23 08:32:57 2020 +0000
+++ b/usr.bin/make/unit-tests/Makefile  Sun Aug 23 09:18:25 2020 +0000
@@ -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-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.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-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.
diff -r 8140e8fcfa50 -r b4b0aca632d4 usr.bin/make/unit-tests/varname-dot-shell.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-shell.exp     Sun Aug 23 09:18:25 2020 +0000
@@ -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
diff -r 8140e8fcfa50 -r b4b0aca632d4 usr.bin/make/unit-tests/varname-dot-shell.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/make/unit-tests/varname-dot-shell.mk      Sun Aug 23 09:18:25 2020 +0000
@@ -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*}



Home | Main Index | Thread Index | Old Index