pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc mk/subst.mk: ignore directories in SUBST_FILES
details: https://anonhg.NetBSD.org/pkgsrc/rev/b3990c59be00
branches: trunk
changeset: 413799:b3990c59be00
user: rillig <rillig%pkgsrc.org@localhost>
date: Sun Mar 22 13:19:50 2020 +0000
description:
mk/subst.mk: ignore directories in SUBST_FILES
Seen in multimedia/libmp4v2, where a pattern also matches the CVS
directory from the distfiles.
diffstat:
mk/subst.mk | 4 +-
regress/infra-unittests/subst.sh | 85 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 2 deletions(-)
diffs (110 lines):
diff -r a8decf4c9a7b -r b3990c59be00 mk/subst.mk
--- a/mk/subst.mk Sun Mar 22 13:15:13 2020 +0000
+++ b/mk/subst.mk Sun Mar 22 13:19:50 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.69 2020/03/22 12:15:59 rillig Exp $
+# $NetBSD: subst.mk,v 1.70 2020/03/22 13:19:50 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -159,7 +159,7 @@
case $$file in /*) ;; *) file="./$$file";; esac; \
tmpfile="$$file.subst.sav"; \
if [ ! -f "$$file" ]; then \
- ${_SUBST_WARN.${_class_}} "Ignoring non-existent file \"$$file\"."; \
+ [ -d "$$file" ] || ${_SUBST_WARN.${_class_}} "Ignoring non-existent file \"$$file\"."; \
elif ${_SUBST_IS_TEXT_FILE_CMD.${_class_}}; then \
${SUBST_FILTER_CMD.${_class_}} \
< "$$file" \
diff -r a8decf4c9a7b -r b3990c59be00 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh Sun Mar 22 13:15:13 2020 +0000
+++ b/regress/infra-unittests/subst.sh Sun Mar 22 13:19:50 2020 +0000
@@ -838,3 +838,88 @@
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
Home |
Main Index |
Thread Index |
Old Index