Source-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: test ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/506f58439b02
branches:  trunk
changeset: 434145:506f58439b02
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu Jun 11 20:10:53 2020 +0000

description:
regress/infra-unittests: test SUBST_FILTER_CMD with empty SUBST_SED

diffstat:

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

diffs (66 lines):

diff -r 9c1d0dbf178f -r 506f58439b02 regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Thu Jun 11 19:55:54 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Thu Jun 11 20:10:53 2020 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: subst.sh,v 1.48 2020/06/11 18:04:41 rillig Exp $
+# $NetBSD: subst.sh,v 1.49 2020/06/11 20:10:53 rillig Exp $
 #
 # Tests for mk/subst.mk.
 #
@@ -38,6 +38,12 @@
                WRKDIR=         $PWD
                WRKSRC=         $PWD
        EOF
+
+       create_file_lines "$mocked_pkgsrcdir/show-pkg-fail-reason.mk" \
+               'show-pkg-fail-reasons: .PHONY' \
+               '.if ${PKG_FAIL_REASON:M*}' \
+               '       @printf "fail reason: %s\n" ${PKG_FAIL_REASON} 1>&2 && exit 1' \
+               '.endif'
 }
 
 
@@ -1527,6 +1533,42 @@
 fi
 
 
+if test_case_begin 'SUBST_FILTER_CMD + empty SUBST_SED'; then
+
+       # If SUBST_FILTER_CMD is defined for a SUBST class,
+       # the corresponding SUBST_SED and SUBST_VARS are ignored.
+       # To avoid redundant variable definitions, this case fails fast.
+       #
+       # This happens even if SUBST_SED or SUBST_VARS are empty since
+       # there is no point in setting these to empty values.
+       # In most cases they are constant and non-empty anyway.
+
+       create_file_lines 'testcase.mk' \
+               'SUBST_CLASSES+=        id' \
+               'SUBST_FILES.id=        file' \
+               'SUBST_FILTER_CMD.id=   tr -d "0-9"' \
+               'SUBST_SED.id=          # empty' \
+               'SUBST_VARS.id=         # empty' \
+               'SUBST_NOOP_OK.id=      no' \
+               '' \
+               '.include "prepare-subst.mk"' \
+               '.include "mk/subst.mk"' \
+               '.include "show-pkg-fail-reason.mk"'
+
+       run_bmake 'testcase.mk' 'show-pkg-fail-reasons' 'subst-id' 1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$tmpdir/output" --file-is-lines \
+               'fail reason: [subst.mk:id] SUBST_FILTER_CMD and SUBST_SED/SUBST_VARS cannot be combined.' \
+               '*** Error code 1' \
+               '' \
+               'Stop.' \
+               "$make: stopped in $PWD"
+
+       test_case_end
+fi
+
+
 if test_case_begin 'effective SUBST_FILTER_CMD in NOOP_OK=no mode'; then
 
        create_file_lines 'testcase.mk' \



Home | Main Index | Thread Index | Old Index