pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/lintpkgsrc lintpkgsrc: add automatic tests



details:   https://anonhg.NetBSD.org/pkgsrc/rev/729a127bdf62
branches:  trunk
changeset: 382521:729a127bdf62
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Jul 30 10:11:45 2022 +0000

description:
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:

 pkgtools/lintpkgsrc/Makefile             |  20 ++++++++++++--------
 pkgtools/lintpkgsrc/files/lintpkgsrc.pl  |   6 +++---
 pkgtools/lintpkgsrc/files/t/pkgversion.t |  15 +++++++++++++++
 3 files changed, 30 insertions(+), 11 deletions(-)

diffs (92 lines):

diff -r 6f4444372008 -r 729a127bdf62 pkgtools/lintpkgsrc/Makefile
--- a/pkgtools/lintpkgsrc/Makefile      Sat Jul 30 09:56:08 2022 +0000
+++ b/pkgtools/lintpkgsrc/Makefile      Sat Jul 30 10:11:45 2022 +0000
@@ -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 @@
 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 @@
 .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 -r 6f4444372008 -r 729a127bdf62 pkgtools/lintpkgsrc/files/lintpkgsrc.pl
--- a/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 09:56:08 2022 +0000
+++ b/pkgtools/lintpkgsrc/files/lintpkgsrc.pl   Sat Jul 30 10:11:45 2022 +0000
@@ -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@localhost>.
 #
@@ -302,7 +302,7 @@
 }
 
 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 @@
        }
 }
 
-main();
+main() unless $ENV{'TESTING_LINTPKGSRC'} eq 'yes';
diff -r 6f4444372008 -r 729a127bdf62 pkgtools/lintpkgsrc/files/t/pkgversion.t
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/lintpkgsrc/files/t/pkgversion.t  Sat Jul 30 10:11:45 2022 +0000
@@ -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'), '');



Home | Main Index | Thread Index | Old Index