summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2020-03-22 13:19:50 +0000
committerrillig <rillig@pkgsrc.org>2020-03-22 13:19:50 +0000
commit7b942317abd96ae312693cdae9826fd1d570c65b (patch)
tree02b38f1e034eff9412fbe344b9dc4709967a88e7 /regress
parentae18df10a8b2a68a45667d826b30e21d33128ed2 (diff)
downloadpkgsrc-7b942317abd96ae312693cdae9826fd1d570c65b.tar.gz
mk/subst.mk: ignore directories in SUBST_FILES
Seen in multimedia/libmp4v2, where a pattern also matches the CVS directory from the distfiles.
Diffstat (limited to 'regress')
-rw-r--r--regress/infra-unittests/subst.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh
index 2a7c174294b..5a01fc44934 100644
--- a/regress/infra-unittests/subst.sh
+++ b/regress/infra-unittests/subst.sh
@@ -838,3 +838,88 @@ if test_case_begin "SUBST_VARS for variables with regex characters"; then
test_case_end
fi
+
+if test_case_begin "pattern matches directory"; then
+
+ # When a pattern matches a directory, that directory is silently
+ # skipped.
+ #
+ # In this test case, the pattern also matches a regular file that
+ # is actually modified. Therefore the pattern has an effect, and
+ # there is no error message.
+
+ create_file_lines "testcase.mk" \
+ 'SUBST_CLASSES+= dir' \
+ 'SUBST_STAGE.dir= pre-configure' \
+ 'SUBST_FILES.dir= sub*' \
+ 'SUBST_VARS.dir= VAR' \
+ 'SUBST_NOOP_OK.dir= no' \
+ '' \
+ 'VAR= value' \
+ '' \
+ '.include "prepare-subst.mk"' \
+ '.include "mk/subst.mk"'
+ mkdir "$tmpdir/subdir"
+ create_file_lines "subdir/subfile" \
+ "@VAR@"
+ create_file_lines "subst-file" \
+ "@VAR@"
+
+ test_file "testcase.mk" "pre-configure" \
+ 1> "$tmpdir/stdout" \
+ 2> "$tmpdir/stderr" \
+ && exitcode=0 || exitcode=$?
+
+ assert_that "subst-file" --file-is-lines "value"
+ assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged
+ assert_that "stdout" --file-is-lines \
+ "=> Substituting \"dir\" in sub*"
+ assert_that "stderr" --file-is-empty
+ assert_that "$exitcode" --equals 0
+
+ test_case_end
+fi
+
+
+if test_case_begin "pattern matches only directory"; then
+
+ # When a pattern matches a directory, that directory is silently
+ # skipped.
+ #
+ # In this test case, the pattern also matches a regular file that
+ # is actually modified. Therefore the pattern has an effect, and
+ # there is no error message.
+
+ create_file_lines "testcase.mk" \
+ 'SUBST_CLASSES+= dir' \
+ 'SUBST_STAGE.dir= pre-configure' \
+ 'SUBST_FILES.dir= sub*' \
+ 'SUBST_VARS.dir= VAR' \
+ 'SUBST_NOOP_OK.dir= no' \
+ '' \
+ 'VAR= value' \
+ '' \
+ '.include "prepare-subst.mk"' \
+ '.include "mk/subst.mk"'
+ mkdir "$tmpdir/subdir"
+ create_file_lines "subdir/subfile" \
+ "@VAR@"
+
+ test_file "testcase.mk" "pre-configure" \
+ 1> "$tmpdir/stdout" \
+ 2> "$tmpdir/stderr" \
+ && exitcode=0 || exitcode=$?
+
+ assert_that "subdir/subfile" --file-is-lines "@VAR@" # unchanged
+ assert_that "stdout" --file-is-lines \
+ "=> Substituting \"dir\" in sub*" \
+ "fail: [subst.mk:dir] The pattern sub* has no effect." \
+ "*** Error code 1" \
+ "" \
+ "Stop." \
+ "$make: stopped in $PWD"
+ assert_that "stderr" --file-is-empty
+ assert_that "$exitcode" --equals 1
+
+ test_case_end
+fi