pkgsrc-Changes archive

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

CVS commit: pkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sun Mar 22 13:19:50 UTC 2020

Modified Files:
        pkgsrc/mk: subst.mk
        pkgsrc/regress/infra-unittests: subst.sh

Log Message:
mk/subst.mk: ignore directories in SUBST_FILES

Seen in multimedia/libmp4v2, where a pattern also matches the CVS
directory from the distfiles.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 pkgsrc/mk/subst.mk
cvs rdiff -u -r1.12 -r1.13 pkgsrc/regress/infra-unittests/subst.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/subst.mk
diff -u pkgsrc/mk/subst.mk:1.69 pkgsrc/mk/subst.mk:1.70
--- pkgsrc/mk/subst.mk:1.69     Sun Mar 22 12:15:59 2020
+++ pkgsrc/mk/subst.mk  Sun Mar 22 13:19:50 2020
@@ -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 @@ ${_SUBST_COOKIE.${_class_}}:
                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"                                      \

Index: pkgsrc/regress/infra-unittests/subst.sh
diff -u pkgsrc/regress/infra-unittests/subst.sh:1.12 pkgsrc/regress/infra-unittests/subst.sh:1.13
--- pkgsrc/regress/infra-unittests/subst.sh:1.12        Sun Mar 22 12:15:59 2020
+++ pkgsrc/regress/infra-unittests/subst.sh     Sun Mar 22 13:19:50 2020
@@ -838,3 +838,88 @@ if test_case_begin "SUBST_VARS for varia
 
        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