pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/regress/subst regress/subst: demonstrate that SUBST_VA...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d4edf974985e
branches: trunk
changeset: 393375:d4edf974985e
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Mar 17 11:28:13 2019 +0000
description:
regress/subst: demonstrate that SUBST_VARS doesn't pass newlines
Sure, it's an edge case and has not been necessary until now.
Nevertheless it's good to see how this can be done.
Variables having dots in their names are also not handled completely
correct. This also didn't occur in practice since the variable names
passed to SUBST_VARS are usually A-Za-z0-9_ only.
diffstat:
regress/subst/Makefile | 44 ++++++++++++++++++++++++++++++++++++--------
regress/subst/PLIST | 2 ++
regress/subst/files/expected | 23 +++++++++++++++++++++++
regress/subst/vars.mk | 5 -----
4 files changed, 61 insertions(+), 13 deletions(-)
diffs (112 lines):
diff -r 0668b358def2 -r d4edf974985e regress/subst/Makefile
--- a/regress/subst/Makefile Sun Mar 17 11:18:55 2019 +0000
+++ b/regress/subst/Makefile Sun Mar 17 11:28:13 2019 +0000
@@ -1,30 +1,58 @@
-# $NetBSD: Makefile,v 1.4 2019/03/17 10:19:36 rillig Exp $
+# $NetBSD: Makefile,v 1.5 2019/03/17 11:28:13 rillig Exp $
#
-DISTNAME= subst-1.0
+DISTNAME= subst-19.03
CATEGORIES= regress
DISTFILES= # none
MAINTAINER= pkgsrc-users%NetBSD.org@localhost
COMMENT= Test the SUBST framework
+LICENSE= 2-clause-bsd
WRKSRC= ${WRKDIR}
-USE_TOOLS+= diff
+USE_TOOLS+= diff printf
SUBST_CLASSES+= vars
SUBST_STAGE.vars= do-build
-SUBST_FILES.vars= vars
-SUBST_VARS.vars= PLAIN DQUOT SQUOT DELIM EVIL1
+SUBST_FILES.vars= vars.after
+SUBST_VARS.vars= PLAIN DQUOT SQUOT DELIM PRINTABLE
+SUBST_VARS.vars+= UNDEFINED
+SUBST_VARS.vars+= BETWEEN_SPACE BETWEEN_TAB BETWEEN_NL
+SUBST_VARS.vars+= BACKSLASHES VAR...... VAR.abcde
+
+PLAIN= hello_world
+DQUOT= "hello world"
+SQUOT= 'hello world'
+DELIM= hello, world
+PRINTABLE= !"\#$$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}
+
+#UNDEFINED= # undefined
-.include "vars.mk"
+# Ensure that leading and trailing whitespace is preserved.
+BETWEEN_SPACE= ${:U }between spaces${:U }
+BETWEEN_TAB= ${:U }between tabs${:U }
+# TODO: currently fails; needs to be fixed in subst.mk
+#BETWEEN_NL= ${.newline}between newlines${.newline}
+
+BACKSLASHES= \" \, \\, \" \' \0\000 \x40 \089 \a \$$
+
+# Ensure that special regex characters may appear in variable names.
+VAR......= dots
+VAR.abcde= letters
+
+do-extract:
+ ${RUN} ${SED} -e /^\#/d -e /^$$/d ${FILESDIR}/expected \
+ > ${WRKSRC}/expected
pre-build:
- for v in ${SUBST_VARS.vars}; do echo "$$v=@$$v@"; done > ${WRKSRC}/vars
+ ${RUN} printf '%s: <@%s@>\n' ${SUBST_VARS.vars:@var@ ${var:Q} ${var:Q} @} \
+ > ${WRKSRC}/vars.before
+ ${RUN} ${CAT} ${WRKSRC}/vars.before > ${WRKSRC}/vars.after
do-build:
@${DO_NADA}
post-build:
- diff -u vars.mk ${WRKSRC}/vars
+ ${RUN} diff -u ${WRKSRC}/expected ${WRKSRC}/vars.after
.include "../../mk/bsd.pkg.mk"
diff -r 0668b358def2 -r d4edf974985e regress/subst/PLIST
--- a/regress/subst/PLIST Sun Mar 17 11:18:55 2019 +0000
+++ b/regress/subst/PLIST Sun Mar 17 11:28:13 2019 +0000
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST,v 1.2 2019/03/17 11:28:13 rillig Exp $
+@comment unused
diff -r 0668b358def2 -r d4edf974985e regress/subst/files/expected
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/subst/files/expected Sun Mar 17 11:28:13 2019 +0000
@@ -0,0 +1,23 @@
+# $NetBSD: expected,v 1.1 2019/03/17 11:28:13 rillig Exp $
+#
+# The expected output from the SUBST_VARS test.
+# Each substituted value is enclosed in <angle brackets> to clearly
+# show where it begins and ends.
+
+PLAIN: <hello_world>
+DQUOT: <"hello world">
+SQUOT: <'hello world'>
+DELIM: <hello, world>
+PRINTABLE: <!"#$%&'()*+,-./09:;<=>?@AZ[\]^_`az{|}>
+
+UNDEFINED: <>
+
+BETWEEN_SPACE: < between spaces >
+BETWEEN_TAB: < between tabs >
+BETWEEN_NL: <>
+
+BACKSLASHES: <\" \, \\, \" \' \0\000 \x40 \089 \a \$>
+
+VAR......: <dots>
+# FIXME: must be <letters> instead of <dots>
+VAR.abcde: <dots>
diff -r 0668b358def2 -r d4edf974985e regress/subst/vars.mk
--- a/regress/subst/vars.mk Sun Mar 17 11:18:55 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-PLAIN=hello_world
-DQUOT="hello world"
-SQUOT='hello world'
-DELIM=hello, world
-EVIL1=h\ello \0\0\0 \\\"\' foo && bar
Home |
Main Index |
Thread Index |
Old Index