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: demon...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/4beb7c5be687
branches:  trunk
changeset: 432105:4beb7c5be687
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Tue May 19 06:09:53 2020 +0000

description:
regress/infra-unittests: demonstrate relative paths in +BUILD_VERSION

Pointed out by wiz@.

This occured in math/libixion/Makefile.common until 2020-05-19, and still
occurs in math/xyconvert/Makefile.  In all other packages, PKGDIR is
prefixed with  ${.CURDIR} and is thus an absolute path.

It should not be necessary to always specify PATCHDIR as an absolute
path, and the code in mk/pkgformat/pkg/metadata.mk seems to be the only
place where relative paths are handled wrong.

diffstat:

 regress/infra-unittests/pkgformat-pkg-metadata.sh |  116 ++++++++++++++++++++++
 1 files changed, 116 insertions(+), 0 deletions(-)

diffs (120 lines):

diff -r 801b0ea80150 -r 4beb7c5be687 regress/infra-unittests/pkgformat-pkg-metadata.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/infra-unittests/pkgformat-pkg-metadata.sh Tue May 19 06:09:53 2020 +0000
@@ -0,0 +1,116 @@
+#! /bin/sh
+# $NetBSD: pkgformat-pkg-metadata.sh,v 1.1 2020/05/19 06:09:53 rillig Exp $
+#
+# Demonstrates how mk/pkgformat/pkg/metadata.mk creates the versioning
+# information in +BUILD_VERSION.
+#
+# As of May 2020, several directories must be prefixed with ${.CURDIR},
+# since otherwise +BUILD_VERSION ends up containing corrupt data.
+#
+
+set -eu
+
+. './test.subr'
+
+test_case_set_up() {
+       create_file 'setup.mk' <<-EOF
+               AWK=            awk
+               CAT=            cat
+               ECHO=           echo
+               GREP=           grep
+               MKDIR=          mkdir -p
+               RM=             rm
+               SED=            sed
+               SORT=           sort
+               TEST=           test
+
+               RUN=            @set -e;
+               INIT_SYSTEM=    rc.d
+               WRKDIR=         $PWD
+               WRKSRC=         $PWD
+               PKGSRCDIR=      $mocked_pkgsrcdir
+       EOF
+}
+
+
+if test_case_begin 'absolute paths'; then
+
+       wrkdir="$PWD"
+       pkgdir="$mocked_pkgsrcdir/category/package"
+       mkdir -p "$pkgdir"
+       cd "$pkgdir"
+
+       cvsid='$''NetBSD: marker ''$'
+       create_file 'Makefile' <<-EOF
+               # $cvsid
+
+               PKGDIR=         \${.CURDIR}
+               FILESDIR=       \${.CURDIR}/files
+               PATCHDIR=       \${.CURDIR}/patches
+               DISTINFO_FILE=  \${.CURDIR}/distinfo
+
+               .include "$wrkdir/setup.mk"
+               .include "$pkgsrcdir/mk/pkgformat/pkg/metadata.mk"
+       EOF
+       create_file_lines 'patches/patch-aa' \
+               "$cvsid"
+       create_file_lines 'files/README' \
+               "$cvsid"
+
+       run_bmake 'Makefile' "$wrkdir/.pkgdb/+BUILD_VERSION" \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$exitcode" --equals '0'
+       assert_that "$tmpdir/output" --file-is-empty
+       assert_that "$wrkdir/.pkgdb/+BUILD_VERSION" --file-is-lines \
+               "category/package/Makefile:     $cvsid" \
+               "category/package/files/README: $cvsid" \
+               "category/package/patches/patch-aa:     $cvsid"
+
+       test_case_end
+fi
+
+
+if test_case_begin 'relative paths'; then
+
+       # As of May 2020, the +BUILD_VERSION contains corrupt data.
+
+       wrkdir="$PWD"
+       pkgdir="$mocked_pkgsrcdir/category/package"
+       mkdir -p "$pkgdir"
+       cd "$pkgdir"
+
+       cvsid='$''NetBSD: marker ''$'
+       create_file 'Makefile' <<-EOF
+               # $cvsid
+
+               PKGDIR=         .
+               FILESDIR=       files
+               PATCHDIR=       patches
+               DISTINFO_FILE=  distinfo
+
+               .include "$wrkdir/setup.mk"
+               .include "$pkgsrcdir/mk/pkgformat/pkg/metadata.mk"
+       EOF
+       create_file_lines 'patches/patch-aa' \
+               "$cvsid"
+       create_file_lines 'files/README' \
+               "$cvsid"
+
+       run_bmake 'Makefile' "$wrkdir/.pkgdb/+BUILD_VERSION" \
+               1> "$tmpdir/output" 2>&1 \
+       && exitcode=0 || exitcode=$?
+
+       assert_that "$exitcode" --equals '0'
+       assert_that "$tmpdir/output" --file-is-empty
+       # FIXME: All files listed here are supposed to be relative to
+       # the pkgsrc root directory.
+       assert_that "$wrkdir/.pkgdb/+BUILD_VERSION" --file-is-lines \
+               "./Makefile:    $cvsid" \
+               "category/package/Makefile:     $cvsid" \
+               "files/README:  $cvsid" \
+               "patches/patch-aa:      $cvsid"
+
+       test_case_end
+fi



Home | Main Index | Thread Index | Old Index