summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2022-07-30 10:11:45 +0000
committerrillig <rillig@pkgsrc.org>2022-07-30 10:11:45 +0000
commitb6eb76114e3309dabf004548d3a2fa60755e6234 (patch)
treeeec37ea7f55d13836a99caef8894ebe9b07e69ed /pkgtools
parentcf6b91fb2e7357f6b6f956806d8d7a25d590712c (diff)
downloadpkgsrc-b6eb76114e3309dabf004548d3a2fa60755e6234.tar.gz
lintpkgsrc: add automatic tests
Not sure whether this form of running tests is the idiomatic one, as lintpkgsrc is not a Perl module but a Perl program, but it works. The number of planned tests (5 for now) seems to be ignored, no idea why.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/lintpkgsrc/Makefile20
-rwxr-xr-xpkgtools/lintpkgsrc/files/lintpkgsrc.pl6
-rw-r--r--pkgtools/lintpkgsrc/files/t/pkgversion.t15
3 files changed, 30 insertions, 11 deletions
diff --git a/pkgtools/lintpkgsrc/Makefile b/pkgtools/lintpkgsrc/Makefile
index 453015b1337..cdbd6ff22ac 100644
--- a/pkgtools/lintpkgsrc/Makefile
+++ b/pkgtools/lintpkgsrc/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.39 2022/06/28 11:35:24 wiz Exp $
+# $NetBSD: Makefile,v 1.40 2022/07/30 10:11:45 rillig Exp $
PKGNAME= lintpkgsrc-4.98
PKGREVISION= 1
@@ -14,18 +14,13 @@ CONFLICTS+= pkglint<4.82
USE_TOOLS+= perl:run
WRKSRC= ${WRKDIR}
-NO_BUILD= yes
USE_LANGUAGES= # none
AUTO_MKDIRS= yes
SUBST_CLASSES+= lp
SUBST_STAGE.lp= post-configure
SUBST_FILES.lp+= lintpkgsrc.0 lintpkgsrc.1 lintpkgsrc.pl
-.if defined(BATCH)
-SUBST_SED.lp+= -e 's;@PKGSRCDIR@;/usr/pkgsrc;g'
-.else
-SUBST_VARS.lp+= PKGSRCDIR
-.endif
+SUBST_SED.lp+= -e 's;@PKGSRCDIR@;${BATCH:D/usr/pkgsrc:U${PKGSRCDIR}};g'
SUBST_VARS.lp+= MAKE
SUBST_VARS.lp+= PERL5
SUBST_VARS.lp+= PKG_SYSCONFDIR
@@ -34,7 +29,16 @@ SUBST_VARS.lp+= PREFIX
.include "../../mk/bsd.prefs.mk"
do-extract:
- cd ${FILESDIR} && cp lintpkgsrc.* ${WRKSRC}/
+ cd ${FILESDIR} && cp -R lintpkgsrc.* t ${WRKSRC}/
+
+do-build:
+ # Nothing
+
+do-test:
+ ${RUN} cd ${WRKSRC}/t; \
+ for test in ./*.t; do \
+ perl "$$test"; \
+ done
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/lintpkgsrc.pl ${DESTDIR}${PREFIX}/bin/lintpkgsrc
diff --git a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
index 824d9967732..21ea5d3d6fb 100755
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
@@ -1,6 +1,6 @@
#!@PERL5@
-# $NetBSD: lintpkgsrc.pl,v 1.34 2022/07/30 09:37:21 rillig Exp $
+# $NetBSD: lintpkgsrc.pl,v 1.35 2022/07/30 10:11:45 rillig Exp $
# Written by David Brownlee <abs@netbsd.org>.
#
@@ -302,7 +302,7 @@ sub canonicalize_pkgname($) {
}
sub convert_to_standard_pkgversion(@) {
- my ($elem, $underscore, @temp);
+ my ($elem, @temp);
# See pkg_install/lib/dewey.c.
# 'nb' has already been handled when we are here.
@@ -1800,4 +1800,4 @@ sub main() {
}
}
-main();
+main() unless $ENV{'TESTING_LINTPKGSRC'} eq 'yes';
diff --git a/pkgtools/lintpkgsrc/files/t/pkgversion.t b/pkgtools/lintpkgsrc/files/t/pkgversion.t
new file mode 100644
index 00000000000..77ffd9aade2
--- /dev/null
+++ b/pkgtools/lintpkgsrc/files/t/pkgversion.t
@@ -0,0 +1,15 @@
+# $NetBSD: pkgversion.t,v 1.1 2022/07/30 10:11:45 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'), '');
+ok(pkgversioncmp('3.4', '<=', '3.4'), 1);
+ok(pkgversioncmp('3.4', '>=', '3.4.0.0.0'), 1);
+ok(pkgversioncmp('3.4nb13', '>=', '3.4'), 1);
+ok(pkgversioncmp('3.4nb13', '<', '3.4'), '');