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 t...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5891be639f25
branches:  trunk
changeset: 414293:5891be639f25
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Mar 25 07:47:10 2020 +0000

description:
regress/infra-unittests: add test for not extracting certain files

diffstat:

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

diffs (53 lines):

diff -r 315a41835f25 -r 5891be639f25 regress/infra-unittests/extract.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/infra-unittests/extract.sh        Wed Mar 25 07:47:10 2020 +0000
@@ -0,0 +1,49 @@
+#! /bin/sh
+#
+# Tests for mk/subst.mk.
+#
+set -eu
+
+. "./test.subr"
+
+# XXX: The mocked pkgsrc directory should be somewhere else.
+rm -r "$tmpdir/pkgsrc"
+
+# XXX: This definition should be available everywhere.
+pkgsrcdir="`cd "$real_pkgsrcdir" && exec pwd`"
+
+if test_case_begin "exclude directory"; then
+
+       # Demonstrates that excluding a directory name also excludes that
+       # directory further down in the hierarchy.
+       #
+       # For example, with BSD tar and GNU tar it is not possible to exclude
+       # only the top-level "contrib" directory but still extract other
+       # contrib directories.
+       #
+       # Experienced in lang/gcc*, which has contrib/ and java-lib/contrib/.
+
+       cd "$tmpdir"
+       mkdir "contrib"
+       echo "file" > "contrib/file"
+       mkdir "other"
+       echo "file" > "other/file"
+       mkdir "other/contrib"
+       echo "file" > "other/contrib/file"
+
+       tar cf "archive.tar" "contrib" "other"
+       rm -r "contrib" "other"
+
+       sh "$pkgsrcdir/mk/extract/extract" -x "archive.tar" "contrib"
+
+       find . -print | LC_ALL=C sort > "extracted"
+
+       assert_that "extracted" --file-is-lines \
+               "." \
+               "./archive.tar" \
+               "./extracted" \
+               "./other" \
+               "./other/file"
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index