pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/lintpkgsrc/files



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Jul 30 17:06:29 UTC 2022

Modified Files:
        pkgsrc/pkgtools/lintpkgsrc/files: lintpkgsrc.pl
        pkgsrc/pkgtools/lintpkgsrc/files/t: packages.t pkgversion.t

Log Message:
lintpkgsrc: test versioned packages, minor cleanup


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r1.1 -r1.2 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t \
    pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.39 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.40
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.39 Sat Jul 30 16:26:14 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Sat Jul 30 17:06:29 2022
@@ -1,6 +1,6 @@
 #!@PERL5@
 
-# $NetBSD: lintpkgsrc.pl,v 1.39 2022/07/30 16:26:14 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.40 2022/07/30 17:06:29 rillig Exp $
 
 # Written by David Brownlee <abs%netbsd.org@localhost>.
 #
@@ -22,7 +22,8 @@ use File::Basename;
 use IPC::Open3;
 use Cwd 'realpath', 'getcwd';
 
-# PkgVer is a unique package + version.
+# PkgVer is a PKGBASE + PKGVERSION, including some of the variables that
+# have been extracted from the package Makefile.
 #
 package PkgVer;
 
@@ -87,7 +88,8 @@ sub store($) {
        }
 }
 
-# Pkgs is all versions of a given package (eg: apache-1.x and apache-2.x)
+# Pkgs collects all versions of a given PKGBASE, e.g. apache-1.3.27 and
+# apache-2.0.46.
 #
 package Pkgs;
 
@@ -106,6 +108,8 @@ sub new($@) {
        return $self;
 }
 
+# Returns all available versions of the package, in decreasing
+# alphabetical(!) order.
 sub versions($) {
        my $self = shift;
 
@@ -117,16 +121,19 @@ sub pkg($) {
        $self->{_pkg};
 }
 
+# Returns all available versioned packages of this PKGBASE, in decreasing
+# alphabetical(!) order.
 sub pkgver($@) {
        my $self = shift;
 
+       my $pkgvers = $self->{_pkgver};
        if (@_) {
-               if ($self->{_pkgver}{$_[0]}) {
-                       return ($self->{_pkgver}{$_[0]});
+               if ($pkgvers->{$_[0]}) {
+                       return ($pkgvers->{$_[0]});
                }
                return;
        }
-       return sort { $b->ver() cmp $a->ver() } values %{$self->{_pkgver}};
+       return sort { $b->ver cmp $a->ver } values %{$pkgvers};
 }
 
 sub latestver($) {
@@ -1787,4 +1794,4 @@ sub main() {
        }
 }
 
-main() unless defined $ENV{'TESTING_LINTPKGSRC'};
+main() unless caller();

Index: pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.1 pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.2
--- pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t:1.1   Sat Jul 30 16:20:18 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/packages.t       Sat Jul 30 17:06:29 2022
@@ -1,13 +1,12 @@
-# $NetBSD: packages.t,v 1.1 2022/07/30 16:20:18 rillig Exp $
+# $NetBSD: packages.t,v 1.2 2022/07/30 17:06:29 rillig Exp $
 
 use strict;
 use warnings;
 use Capture::Tiny 'capture';
 use Test;
 
-BEGIN { plan tests => 1; }
+BEGIN { plan tests => 8; }
 
-$ENV{'TESTING_LINTPKGSRC'} = 'yes';
 require('../lintpkgsrc.pl');
 
 sub test_package_variables() {
@@ -18,6 +17,24 @@ sub test_package_variables() {
 
        ok($pkgbase_1_0->var('NAME'), 'value');
        ok($pkgbase_1_0->var('undefined'), undef);
+
+       my $pkgbase_2_0 = $pkglist->add('pkgbase', '2.0');
+       my $pkgbase_1_5 = $pkglist->add('pkgbase', '1.5');
+       my $pkgbase_1_10 = $pkglist->add('pkgbase', '1.10');
+
+       $pkgbase_2_0->var('COMMENT', 'Version 2 of the package');
+
+       ok($pkglist->pkgs('unknown-pkgbase'), undef);
+
+       # The versions are sorted in decreasing alphabetical order.
+       my $versions = join(', ', $pkglist->pkgs('pkgbase')->versions());
+       ok($versions, '2.0, 1.5, 1.10, 1.0');
+
+       # The versioned packages are sorted in decreasing alphabetical order.
+       my @pkgvers = $pkglist->pkgver('pkgbase');
+       ok(join(', ', map { $_->ver } @pkgvers), '2.0, 1.5, 1.10, 1.0');
+       ok($pkgvers[0], $pkgbase_2_0);
+       ok($pkgvers[3], $pkgbase_1_0);
 }
 
 # Demonstrate how the package data is stored in the cache file.
Index: pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t
diff -u pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t:1.1 pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t:1.2
--- pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t:1.1 Sat Jul 30 10:11:45 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t     Sat Jul 30 17:06:29 2022
@@ -1,11 +1,10 @@
-# $NetBSD: pkgversion.t,v 1.1 2022/07/30 10:11:45 rillig Exp $
+# $NetBSD: pkgversion.t,v 1.2 2022/07/30 17:06:29 rillig Exp $
 use strict;
 use warnings;
 use Test;
 
 BEGIN { plan tests => 5; }
 
-$ENV{'TESTING_LINTPKGSRC'} = 'yes';
 require('../lintpkgsrc.pl');
 
 ok(pkgversioncmp('3.4', '<', '3.4'), '');



Home | Main Index | Thread Index | Old Index