pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc mk/subst.mk: warn about all noop patterns before error...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/68bace6a3fe9
branches:  trunk
changeset: 428042:68bace6a3fe9
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Apr 23 19:30:29 2020 +0000

description:
mk/subst.mk: warn about all noop patterns before erroring out

diffstat:

 mk/subst.mk                      |  21 ++++++++++++++++-----
 regress/infra-unittests/subst.sh |   9 +++++----
 2 files changed, 21 insertions(+), 9 deletions(-)

diffs (76 lines):

diff -r 05c0aaf576ec -r 68bace6a3fe9 mk/subst.mk
--- a/mk/subst.mk       Thu Apr 23 19:16:49 2020 +0000
+++ b/mk/subst.mk       Thu Apr 23 19:30:29 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.82 2020/04/23 19:16:49 rillig Exp $
+# $NetBSD: subst.mk,v 1.83 2020/04/23 19:30:29 rillig Exp $
 #
 # The subst framework replaces text in one or more files in the WRKSRC
 # directory. Packages can define several ``classes'' of replacements.
@@ -156,13 +156,16 @@
 subst-${class}: ${_SUBST_COOKIE.${class}}
 
 ${_SUBST_COOKIE.${class}}:
-       ${RUN}                                                          \
+       ${RUN} set -u;                                                  \
        message=${SUBST_MESSAGE.${class}:Q};                            \
        [ "$$message" ] && ${ECHO_SUBST_MSG} "$$message";               \
        \
        cd ${WRKSRC};                                                   \
        patterns=${SUBST_FILES.${class}:Q};                             \
        set -f;                                                         \
+       noop_count='';                                                  \
+       noop_patterns='';                                               \
+       noop_sep='';                                                    \
        for pattern in $$patterns; do                                   \
                set +f;                                                 \
                changed=no;                                             \
@@ -191,10 +194,18 @@
                        ${ECHO} "$$file" >> ${.TARGET}.tmp;             \
                done;                                                   \
        \
-               [ "$$changed,${SUBST_NOOP_OK.${class}:tl}" = no,no ]    \
-               && ${FAIL_MSG} "[subst.mk:${class}] The filename pattern \"$$pattern\" has no effect."; \
-       done; \
+               [ "$$changed,${SUBST_NOOP_OK.${class}:tl}" = no,no ] && { \
+                       noop_count="$$noop_count+";                     \
+                       noop_patterns="$$noop_patterns$$noop_sep$$pattern"; \
+                       noop_sep=" ";                                   \
+               };                                                      \
+       done;                                                           \
        \
+       case $$noop_count in                                            \
+       ('')    ;;                                                      \
+       (+)     ${FAIL_MSG} "[subst.mk:${class}] The filename pattern \"$$noop_patterns\" has no effect.";; \
+       (*)     ${FAIL_MSG} "[subst.mk:${class}] The filename patterns \"$$noop_patterns\" have no effect."; \
+       esac;                                                           \
        ${TOUCH} ${TOUCH_FLAGS} ${.TARGET}.tmp;                         \
        ${MV} ${.TARGET}.tmp ${.TARGET}
 .endfor
diff -r 05c0aaf576ec -r 68bace6a3fe9 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Thu Apr 23 19:16:49 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Thu Apr 23 19:30:29 2020 +0000
@@ -938,10 +938,10 @@
 fi
 
 
-if test_case_begin "first filename pattern has no effect"; then
+if test_case_begin "two filename patterns have no effect"; then
 
-       # All patterns of SUBST_FILES should be applied before erroring out.
-       # TODO: also warn about file2
+       # All patterns of SUBST_FILES should be applied before erroring out,
+       # to give a complete picture of the situation.
 
        create_file_lines "testcase.mk" \
                'SUBST_CLASSES+=        id' \
@@ -963,7 +963,8 @@
        assert_that "out" --file-is-lines \
                '=> Substituting "id" in file1 file2' \
                'warning: [subst.mk:id] Nothing changed in "file1".' \
-               'fail: [subst.mk:id] The filename pattern "file1" has no effect.' \
+               'warning: [subst.mk:id] Nothing changed in "file2".' \
+               'fail: [subst.mk:id] The filename patterns "file1 file2" have no effect.' \
                '*** Error code 1' \
                '' \
                'Stop.' \



Home | Main Index | Thread Index | Old Index