Received: by mail.netbsd.org (Postfix, from userid 605) id 9B0A985062; Sat, 27 Jun 2020 10:51:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 244478505C for ; Sat, 27 Jun 2020 10:51:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 3WKl5dccCDBo for ; Sat, 27 Jun 2020 10:51:12 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 87B3184D28 for ; Sat, 27 Jun 2020 10:51:12 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 7FD9BFB28; Sat, 27 Jun 2020 10:51:12 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1593255072147700" MIME-Version: 1.0 Date: Sat, 27 Jun 2020 10:51:12 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/regress/infra-unittests To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200627105112.7FD9BFB28@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1593255072147700 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Sat Jun 27 10:51:12 UTC 2020 Added Files: pkgsrc/regress/infra-unittests: haskell.sh Log Message: regress/infra-unittests: add very basic tests for mk/haskell.mk To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 pkgsrc/regress/infra-unittests/haskell.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_1593255072147700 Content-Disposition: inline Content-Length: 4056 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Added files: Index: pkgsrc/regress/infra-unittests/haskell.sh diff -u /dev/null pkgsrc/regress/infra-unittests/haskell.sh:1.1 --- /dev/null Sat Jun 27 10:51:12 2020 +++ pkgsrc/regress/infra-unittests/haskell.sh Sat Jun 27 10:51:12 2020 @@ -0,0 +1,177 @@ +#! /bin/sh +# $NetBSD: haskell.sh,v 1.1 2020/06/27 10:51:12 rillig Exp $ +# +# Tests for mk/haskell.mk. +# + +set -eu + +. './test.subr' + +link_from_pkgsrc() { + for f in "$@"; do + mkdir -p "$mocked_pkgsrcdir/$(dirname "$f")" + rm -f "$mocked_pkgsrcdir/$f" + ln -s "$pkgsrcdir/$f" "$mocked_pkgsrcdir/$f" + done +} + +test_case_set_up() { + + destdir="$PWD/destdir" + prefix="$PWD/prefix" + pkgdir="$mocked_pkgsrcdir/category/package" + + mock_ghc=$(mock_cmd ghc \ + --when-args '-V' --then-output 'The Glorious Glasgow Haskell Compilation System, version 8.8.1' + ) + + mkdir -p "$prefix/bin" + mv "$mock_ghc" "$prefix/bin/" + + rm -rf "$mocked_pkgsrcdir" + mkdir -p "$pkgdir" + cd "$mocked_pkgsrcdir" + + create_file 'mk/bsd.fast.prefs.mk' <<-EOF + OPSYS= Opsys + HASKELL_COMPILER= ghc + SHLIB_TYPE= ELF + + AWK= awk + CAT= cat + CUT= cut + ECHO= echo + FIND= find + GREP= grep + MKDIR= mkdir -p + PKGSRC_SETENV= env + SORT= sort + TRUE= true + EOF + create_file 'lang/ghc88/buildlink3.mk' <<-EOF + # Nothing essential + EOF + create_file 'main.mk' < "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + 'PLIST status: missing' + + test_case_end +fi + + +if test_case_begin 'PLIST status: plain'; then + + # See textproc/hs-cgrep/PLIST, r1.4. + + create_file 'Makefile' <<-EOF + DISTNAME= cgrep-6.6.30 + + .include "../../main.mk" + EOF + create_file 'PLIST' <<-EOF + bin/cgrep + share/doc/x86_64-ghc-8.8.1/cgrep-\${PKGVERSION}/LICENSE + @pkgdir lib/cgrep-\${PKGVERSION}/ghc-8.8.1 + EOF + + "$make" 'show-plist-status' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + 'PLIST status: plain' + + test_case_end +fi + + +if test_case_begin 'PLIST status: outdated'; then + + # See devel/hs-hashable/PLIST, r1.1. + + create_file 'Makefile' <<-EOF + DISTNAME= hashable-1.3.0.0 + + .include "../../main.mk" + EOF + create_file 'PLIST' <<-EOF + lib/hashable-\${PKGVERSION}/\${HASKELL_VERSION}/Data/Hashable.hi + lib/hashable-\${PKGVERSION}/\${HASKELL_VERSION}/package-description + share/doc/hashable-\${PKGVERSION}/LICENSE + \${PLIST.doc}share/doc/hashable-\${PKGVERSION}/html/Data-Hashable.html + EOF + + "$make" 'show-plist-status' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + # TODO: should be 'outdated' because of 'package-description' + assert_that "$tmpdir/output" --file-is-lines \ + 'PLIST status: plain' + + test_case_end +fi + + +if test_case_begin 'PLIST status: lib-ok'; then + + # See devel/hs-hashable/PLIST, r1.3. + + create_file 'Makefile' <<-EOF + DISTNAME= hashable-1.3.0.0 + + .include "../../main.mk" + EOF + create_file 'PLIST' <<-'EOF' + ${HS_INTF}/package-description + ${HS_INTF}/package-id + ${HS_IMPL}/Data/Hashable.dyn_hi + lib/${HS_PLATFORM}/libHS${HS_PKGID}-${HS_VER}.so + ${HS_DOCS}/LICENSE + EOF + + "$make" 'show-plist-status' 1> "$tmpdir/output" 2>&1 \ + && exitcode=0 || exitcode=$? + + assert_that "$tmpdir/output" --file-is-lines \ + 'PLIST status: lib-ok' + + test_case_end +fi --_----------=_1593255072147700--