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/93cff09a4c3b
branches:  trunk
changeset: 425336:93cff09a4c3b
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Mar 21 12:47:13 2020 +0000

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

diffstat:

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

diffs (103 lines):

diff -r 919a53b2ef40 -r 93cff09a4c3b regress/infra-unittests/subst.sh
--- a/regress/infra-unittests/subst.sh  Sat Mar 21 12:29:01 2020 +0000
+++ b/regress/infra-unittests/subst.sh  Sat Mar 21 12:47:13 2020 +0000
@@ -14,6 +14,7 @@
 # The tools that are used by subst.mk
 CHMOD=         chmod-is-not-used
 CMP=           cmp
+DIFF=          diff
 ECHO=          echo
 MKDIR=         mkdir -p
 MV=            mv
@@ -538,3 +539,91 @@
 
        test_case_end
 fi
+
+
+if test_case_begin "several SUBST classes"; then
+
+       # It's ok to have several SUBST classes that apply to the same file.
+       # The order of execution is not guaranteed though.
+
+       create_file_lines "file" "zero one two three four"
+
+       create_file "testcase.mk" <<EOF
+SUBST_CLASSES+=                one
+SUBST_STAGE.one=       pre-configure
+SUBST_FILES.one=       file
+SUBST_SED.one=         -e 's,one,I,'
+
+SUBST_CLASSES+=                two
+SUBST_STAGE.two=       pre-configure
+SUBST_FILES.two=       file
+SUBST_SED.two=         -e 's,two,II,'
+
+SUBST_CLASSES+=                three
+SUBST_STAGE.three=     pre-configure
+SUBST_FILES.three=     file
+SUBST_SED.three=       -e 's,three,III,'
+
+.include "prepare-subst.mk"
+.include "mk/subst.mk"
+EOF
+
+       test_file "testcase.mk" "pre-configure" \
+               1> "$tmpdir/stdout" \
+               2> "$tmpdir/stderr" \
+       && exitcode=0 || exitcode=$?
+
+       # The order of the above output is not guaranteed.
+       LC_ALL=C sort < "$tmpdir/stdout" > "$tmpdir/stdout-sorted"
+
+       assert_that "file" --file-is-lines "zero I II III four"
+       assert_that "stdout-sorted" --file-is-lines \
+               "=> Substituting \"one\" in file" \
+               "=> Substituting \"three\" in file" \
+               "=> Substituting \"two\" in file"
+       assert_that "stderr" --file-is-empty
+       assert_that "$exitcode" --equals 0
+
+       test_case_end
+fi
+
+
+if test_case_begin "show diff"; then
+
+       create_file_lines "file" "one" "two" "three"
+
+       create_file "testcase.mk" <<EOF
+SUBST_CLASSES+=                two
+SUBST_STAGE.two=       pre-configure
+SUBST_FILES.two=       file
+SUBST_SED.two=         -e 's,two,II,'
+SUBST_SHOW_DIFF.two=   yes
+
+.include "prepare-subst.mk"
+.include "mk/subst.mk"
+EOF
+
+       LC_ALL=C \
+       test_file "testcase.mk" "pre-configure" \
+               1> "$tmpdir/stdout" \
+               2> "$tmpdir/stderr" \
+       && exitcode=0 || exitcode=$?
+
+       awk '{ if (/^... \.\/.*/) { print $1 " " $2 " (filtered timestamp)" } else { print $0 } }' \
+       < "$tmpdir/stdout" > "$tmpdir/stdout-filtered"
+
+       assert_that "file" --file-is-lines "one" "II" "three"
+       assert_that "stdout-filtered" --file-is-lines \
+               "=> Substituting \"two\" in file" \
+               "--- ./file (filtered timestamp)" \
+               "+++ ./file.subst.sav (filtered timestamp)" \
+               "@@ -1,3 +1,3 @@" \
+               " one" \
+               "-two" \
+               "+II" \
+               " three"
+       assert_that "stderr" --file-is-empty
+       assert_that "$exitcode" --equals 0
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index