Source-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/regress/infra-unittests regress/infra-unittests: demon...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5bb131fa988b
branches:  trunk
changeset: 433647:5bb131fa988b
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jun 06 13:00:52 2020 +0000

description:
regress/infra-unittests: demonstrate wrong SUBST no-op failure

Discovered by Juraj in mail/policyd-weight.

https://mail-index.netbsd.org/pkgsrc-changes/2020/06/06/msg215480.html

diffstat:

 regress/infra-unittests/subst.sh |  47 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 1 deletions(-)

diffs (59 lines):

diff -r c77fb03127a6 -r 5bb131fa988b regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Sat Jun 06 12:22:17 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Sat Jun 06 13:00:52 2020 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: subst.sh,v 1.43 2020/05/19 05:14:18 rillig Exp $
+# $NetBSD: subst.sh,v 1.44 2020/06/06 13:00:52 rillig Exp $
 #
 # Tests for mk/subst.mk.
 #
@@ -1634,3 +1634,48 @@
 
        test_case_end
 fi
+
+
+if test_case_begin 'several substitution, only one applies to file'; then
+
+       # https://mail-index.netbsd.org/pkgsrc-changes/2020/06/06/msg215480.html
+
+       create_file 'testcase.mk' <<-EOF
+               SUBST_CLASSES+=         id
+               SUBST_FILES.id=         first second
+               SUBST_SED.id=           -e 's,first,first-modified,'
+               SUBST_SED.id+=          -e 's,second,second,'
+               SUBST_NOOP_OK.id=       no
+
+               .include "prepare-subst.mk"
+               .include "mk/subst.mk"
+       EOF
+       create_file_lines 'first' 'first'
+       create_file_lines 'second' 'second'
+
+       run_bmake 'testcase.mk' 'subst-id' 1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       # FIXME: This is not the intended behavior.
+       # Each of the files contains at least one of the sed patterns,
+       # therefore the substitutions _could_ have an effect, depending
+       # on the pkgsrc configuration.
+       #
+       # Instead of testing whether the sed command is an identity
+       # substitution, the original idea was to find files that contain
+       # _none_ of the patterns.
+       #
+       # The proper fix might be as simple as replacing the "all" with an
+       # "any" in mk/scripts/subst-identity.awk.  This would also nicely
+       # remove the special handling of an empty command line.
+       assert_that "$tmpdir/output" --file-is-lines \
+               '=> Substituting "id" in first second' \
+               'warning: [subst.mk:id] Nothing changed in "second".' \
+               'fail: [subst.mk:id] The filename pattern "second" has no effect.' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index