pkgsrc-Changes archive

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

CVS commit: pkgsrc/pkgtools/lintpkgsrc



Module Name:    pkgsrc
Committed By:   rillig
Date:           Sat Jul 30 10:11:45 UTC 2022

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

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 pkgsrc/pkgtools/lintpkgsrc/Makefile
cvs rdiff -u -r1.34 -r1.35 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
cvs rdiff -u -r0 -r1.1 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/Makefile
diff -u pkgsrc/pkgtools/lintpkgsrc/Makefile:1.39 pkgsrc/pkgtools/lintpkgsrc/Makefile:1.40
--- pkgsrc/pkgtools/lintpkgsrc/Makefile:1.39    Tue Jun 28 11:35:24 2022
+++ pkgsrc/pkgtools/lintpkgsrc/Makefile Sat Jul 30 10:11:45 2022
@@ -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

Index: pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl
diff -u pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.34 pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.35
--- pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl:1.34 Sat Jul 30 09:37:21 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/lintpkgsrc.pl      Sat Jul 30 10:11:45 2022
@@ -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 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';

Added files:

Index: pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t
diff -u /dev/null pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t:1.1
--- /dev/null   Sat Jul 30 10:11:45 2022
+++ pkgsrc/pkgtools/lintpkgsrc/files/t/pkgversion.t     Sat Jul 30 10:11:45 2022
@@ -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