pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/regress/infra-unittests regress/infra-unittests: add m...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/20888ee50b3f
branches:  trunk
changeset: 428029:20888ee50b3f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Apr 23 18:30:37 2020 +0000

description:
regress/infra-unittests: add more tests for subst.mk

diffstat:

 regress/infra-unittests/subst.sh |  94 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 94 insertions(+), 0 deletions(-)

diffs (101 lines):

diff -r 5a9473409ccc -r 20888ee50b3f regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Thu Apr 23 18:30:30 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Thu Apr 23 18:30:37 2020 +0000
@@ -971,3 +971,97 @@
 
        test_case_end
 fi
+
+
+if test_case_begin "empty SUBST_FILES"; then
+
+       # An empty SUBST_FILES section is ok.
+       # It may have been produced by a shell command like find(1).
+
+       create_file_lines "testcase.mk" \
+               'SUBST_CLASSES+=        id' \
+               'SUBST_STAGE.id=        pre-configure' \
+               'SUBST_FILES.id=        # none' \
+               'SUBST_SED.id=          -e s,from,to,' \
+               'SUBST_NOOP_OK.id=      no' \
+               '' \
+               'all:' \
+               '       @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \
+               '' \
+               '.include "prepare-subst.mk"' \
+               '.include "mk/subst.mk"'
+
+       run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "out" --file-is-lines \
+               '=> Substituting "id" in ' \
+               'ok'
+
+       test_case_end
+fi
+
+
+if test_case_begin "empty SUBST_SED"; then
+
+       create_file_lines "testcase.mk" \
+               'SUBST_CLASSES+=        id' \
+               'SUBST_STAGE.id=        pre-configure' \
+               'SUBST_FILES.id=        file' \
+               'SUBST_SED.id=          # none' \
+               'SUBST_NOOP_OK.id=      no' \
+               '' \
+               'all:' \
+               '       @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \
+               '' \
+               '.include "prepare-subst.mk"' \
+               '.include "mk/subst.mk"'
+
+       run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "out" --file-is-lines \
+               '=> Substituting "id" in file' \
+               'warning: [subst.mk:id] Ignoring non-existent file "./file".' \
+               'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi
+
+
+if test_case_begin "typo in SUBST_CLASSES"; then
+
+       # Look closely. The SUBST_CLASSES line contains a typo.
+       # subst.mk does not catch this, but pkglint does.
+
+       create_file_lines "testcase.mk" \
+               'SUBST_CLASSES=+        id' \
+               'SUBST_STAGE.id=        pre-configure' \
+               'SUBST_FILES.id=        file' \
+               'SUBST_SED.id=          # none' \
+               'SUBST_NOOP_OK.id=      no' \
+               '' \
+               'all:' \
+               '       @printf "%s\n" ${PKG_FAIL_REASON:Uok}' \
+               '' \
+               '.include "prepare-subst.mk"' \
+               '.include "mk/subst.mk"'
+
+       run_bmake "testcase.mk" "pre-configure" "all" 1> "$tmpdir/out" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "out" --file-is-lines \
+               '=> Substituting "id" in file' \
+               'warning: [subst.mk:id] Ignoring non-existent file "./file".' \
+               'fail: [subst.mk:id] The filename pattern "file" has no effect.' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index