pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc/files lintpkgsrc: test versioned p...
details: https://anonhg.NetBSD.org/pkgsrc/rev/d5f1f9d39d0f
branches: trunk
changeset: 382537:d5f1f9d39d0f
user: rillig <rillig%pkgsrc.org@localhost>
date: Sat Jul 30 17:06:29 2022 +0000
description:
lintpkgsrc: test versioned packages, minor cleanup
diffstat:
pkgtools/lintpkgsrc/files/lintpkgsrc.pl | 21 ++++++++++++++-------
pkgtools/lintpkgsrc/files/t/packages.t | 23 ++++++++++++++++++++---
pkgtools/lintpkgsrc/files/t/pkgversion.t | 3 +--
3 files changed, 35 insertions(+), 12 deletions(-)
diffs (129 lines):
diff -r d7450040605b -r d5f1f9d39d0f pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Sat Jul 30 16:26:14 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl Sat Jul 30 17:06:29 2022 +0000
@@ -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 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 @@
}
}
-# 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 @@
return $self;
}
+# Returns all available versions of the package, in decreasing
+# alphabetical(!) order.
sub versions($) {
my $self = shift;
@@ -117,16 +121,19 @@
$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 @@
}
}
-main() unless defined $ENV{'TESTING_LINTPKGSRC'};
+main() unless caller();
diff -r d7450040605b -r d5f1f9d39d0f pkgtools/lintpkgsrc/files/t/packages.t
--- a/pkgtools/lintpkgsrc/files/t/packages.t Sat Jul 30 16:26:14 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/packages.t Sat Jul 30 17:06:29 2022 +0000
@@ -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 @@
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.
diff -r d7450040605b -r d5f1f9d39d0f pkgtools/lintpkgsrc/files/t/pkgversion.t
--- a/pkgtools/lintpkgsrc/files/t/pkgversion.t Sat Jul 30 16:26:14 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/t/pkgversion.t Sat Jul 30 17:06:29 2022 +0000
@@ -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