summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-06-06 13:00:52 +0000
committerrillig <rillig@pkgsrc.org>2020-06-06 13:00:52 +0000
commitc07204d7317884d0141c06b37dbce47ce090e2fd (patch)
treed2080d01e1ac33376850b549b6e87b78945be16a /regress
parent84e41ed3f7b82c1e0752e5e8dd84a284c9deeda5 (diff)
downloadpkgsrc-c07204d7317884d0141c06b37dbce47ce090e2fd.tar.gz
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 (limited to 'regress')
-rw-r--r--regress/infra-unittests/subst.sh47
1 files changed, 46 insertions, 1 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh
index e4e613af2c7..5ed5cac2dde 100644
--- a/regress/infra-unittests/subst.sh
+++ b/regress/infra-unittests/subst.sh
@@ -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 @@ if test_case_begin 'multiple sed commands with semicolon'; then
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