pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/url2pkg/files pkgtools/url2pkg: add a few mor...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/f094609b338d
branches:  trunk
changeset: 338114:f094609b338d
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Aug 18 18:02:48 2019 +0000

description:
pkgtools/url2pkg: add a few more tests

diffstat:

 pkgtools/url2pkg/files/url2pkg.pl |  18 ++++++------
 pkgtools/url2pkg/files/url2pkg.t  |  58 ++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 12 deletions(-)

diffs (121 lines):

diff -r e283f3fb6054 -r f094609b338d pkgtools/url2pkg/files/url2pkg.pl
--- a/pkgtools/url2pkg/files/url2pkg.pl Sun Aug 18 17:57:55 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.pl Sun Aug 18 18:02:48 2019 +0000
@@ -1,5 +1,5 @@
 #! @PERL5@
-# $NetBSD: url2pkg.pl,v 1.61 2019/08/18 17:34:13 rillig Exp $
+# $NetBSD: url2pkg.pl,v 1.62 2019/08/18 18:02:48 rillig Exp $
 #
 
 # Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -647,15 +647,15 @@
        my $pkgbase1 = substr($pkgbase, 0, 1);
        my $pkgversion_norev = $old{"DISTNAME"} =~ s/^v//r;
 
-       my @tx_lines = @$lines;
-       if (lines_remove(\@tx_lines, "GITHUB_PROJECT")
-               && lines_set(\@tx_lines, "DISTNAME", "$pkgbase-$pkgversion_norev")
-               && lines_set(\@tx_lines, "PKGNAME", "\${PYPKGPREFIX}-\${DISTNAME}")
-               && lines_set(\@tx_lines, "MASTER_SITES", "\${MASTER_SITE_PYPI:=$pkgbase1/$pkgbase/}")
-               && lines_remove(\@tx_lines, "DIST_SUBDIR")
-               && (lines_remove_if(\@tx_lines, "EXTRACT_SUFX", ".zip") || true)) {
+       my @lines = @$lines;
+       if (lines_remove(\@lines, "GITHUB_PROJECT")
+               && lines_set(\@lines, "DISTNAME", "$pkgbase-$pkgversion_norev")
+               && lines_set(\@lines, "PKGNAME", "\${PYPKGPREFIX}-\${DISTNAME}")
+               && lines_set(\@lines, "MASTER_SITES", "\${MASTER_SITE_PYPI:=$pkgbase1/$pkgbase/}")
+               && lines_remove(\@lines, "DIST_SUBDIR")
+               && (lines_remove_if(\@lines, "EXTRACT_SUFX", ".zip") || true)) {
 
-               @$lines = @tx_lines;
+               @$lines = @lines;
                $regenerate_distinfo = true
        }
 }
diff -r e283f3fb6054 -r f094609b338d pkgtools/url2pkg/files/url2pkg.t
--- a/pkgtools/url2pkg/files/url2pkg.t  Sun Aug 18 17:57:55 2019 +0000
+++ b/pkgtools/url2pkg/files/url2pkg.t  Sun Aug 18 18:02:48 2019 +0000
@@ -1,5 +1,5 @@
 # -*- perl -*-
-# $NetBSD: url2pkg.t,v 1.5 2019/08/18 17:34:13 rillig Exp $
+# $NetBSD: url2pkg.t,v 1.6 2019/08/18 18:02:48 rillig Exp $
 
 require "url2pkg.pl";
 
@@ -83,7 +83,7 @@
        is_deeply($lines, ["VARNAME+=\tvalue appended"]);
 }
 
-sub test_generate_initial_package_Makefile_lines__GitHub() {
+sub test_generate_initial_package_Makefile_lines__GitHub_archive() {
        my $url = "https://github.com/org/proj/archive/v1.0.0.tar.gz";;
 
        my @lines = generate_initial_package_Makefile_lines($url);
@@ -107,6 +107,56 @@
        ]);
 }
 
+sub test_generate_initial_package_Makefile_lines__GitHub_release_containing_project_name() {
+       my $url = "https://github.com/org/proj/releases/download/1.0.0/proj.zip";;
+
+       my @lines = generate_initial_package_Makefile_lines($url);
+
+       is_deeply(\@lines, [
+               "# \$" . "NetBSD\$",
+               "",
+               "DISTNAME=\tproj",
+               "CATEGORIES=\tpkgtools",
+               "MASTER_SITES=\t\${MASTER_SITE_GITHUB:=org/}",
+               "GITHUB_RELEASE=\t1.0.0",
+               "EXTRACT_SUFX=\t.zip",
+               "",
+               "MAINTAINER=\tINSERT_YOUR_MAIL_ADDRESS_HERE",
+               "HOMEPAGE=\thttps://github.com/org/proj/";,
+               "COMMENT=\tTODO: Short description of the package",
+               "#LICENSE=\t# TODO: (see mk/license.mk)",
+               "",
+               "# url2pkg-marker (please do not remove this line.)",
+               ".include \"../../mk/bsd.pkg.mk\""
+       ]);
+}
+
+sub test_generate_initial_package_Makefile_lines__GitHub_release_not_containing_project_name() {
+       my $url = "https://github.com/org/proj/releases/download/1.0.0/data.zip";;
+
+       my @lines = generate_initial_package_Makefile_lines($url);
+
+       is_deeply(\@lines, [
+               "# \$" . "NetBSD\$",
+               "",
+               "GITHUB_PROJECT=\tproj",
+               "DISTNAME=\tdata",
+               "CATEGORIES=\tpkgtools",
+               "MASTER_SITES=\t\${MASTER_SITE_GITHUB:=org/}",
+               "GITHUB_RELEASE=\t1.0.0",
+               "EXTRACT_SUFX=\t.zip",
+               "DIST_SUBDIR=\t\${GITHUB_PROJECT}",
+               "",
+               "MAINTAINER=\tINSERT_YOUR_MAIL_ADDRESS_HERE",
+               "HOMEPAGE=\thttps://github.com/org/proj/";,
+               "COMMENT=\tTODO: Short description of the package",
+               "#LICENSE=\t# TODO: (see mk/license.mk)",
+               "",
+               "# url2pkg-marker (please do not remove this line.)",
+               ".include \"../../mk/bsd.pkg.mk\""
+       ]);
+}
+
 sub test_all() {
        my $pkgsrcdir = $ENV{"PKGSRCDIR"} or die;
        chdir("$pkgsrcdir/pkgtools/url2pkg") or die;
@@ -118,7 +168,9 @@
        test_lines_append__only_comment();
        test_lines_append__value_with_comment();
        test_lines_append__value_without_comment();
-       test_generate_initial_package_Makefile_lines__GitHub();
+       test_generate_initial_package_Makefile_lines__GitHub_archive();
+       test_generate_initial_package_Makefile_lines__GitHub_release_containing_project_name();
+       test_generate_initial_package_Makefile_lines__GitHub_release_not_containing_project_name();
 
        done_testing();
 }



Home | Main Index | Thread Index | Old Index