[devscripts] 01/01: Added test for licensecheck versus Software::License

Nicholas Bamber periapt at moszumanska.debian.org
Sat Nov 28 10:39:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

periapt pushed a commit to branch master
in repository devscripts.

commit cae7c5ddbc9dcd5b61a4efd1cf69fad35ad6115e
Author: Nicholas Bamber <nicholas at periapt.co.uk>
Date:   Sat Nov 28 10:25:14 2015 +0000

    Added test for licensecheck versus Software::License
---
 debian/changelog          |  1 +
 debian/control            |  4 ++-
 debian/tests/control      |  2 +-
 test/Makefile             |  2 ++
 test/test_licensecheck_SL | 78 +++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index b0af2b9..fa6cad5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,7 @@ devscripts (2.15.10) UNRELEASED; urgency=medium
   * licensecheck:
     - Tweaked parselicense to capture 'and or' as well as
       'and/or' in GPL licenses (Closes: #559429)
+    - Added test for licensecheck versus Software::License
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/debian/control b/debian/control
index adbbd76..803552f 100644
--- a/debian/control
+++ b/debian/control
@@ -33,7 +33,9 @@ Build-Depends: bash-completion,
                wdiff,
                xsltproc,
                xz-utils,
-               zip
+               zip,
+               libsoftware-license-perl,
+               libuniversal-require-perl
 Testsuite: autopkgtest
 Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/devscripts.git
 Vcs-Git: git://anonscm.debian.org/collab-maint/devscripts.git
diff --git a/debian/tests/control b/debian/tests/control
index 839b087..e637653 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -1,3 +1,3 @@
 Tests: shunit2
-Depends: devscripts, libdistro-info-perl, zip, shunit2
+Depends: devscripts, libdistro-info-perl, zip, shunit2, libsoftware-license-perl, libuniversal-require-perl
 Restrictions: allow-stderr needs-recommends
diff --git a/test/Makefile b/test/Makefile
index 16b48b6..a507b54 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -5,6 +5,7 @@ test:
 	./test_debchange
 	./test_debdiff
 	./test_licensecheck
+	./test_licensecheck_SL
 	./test_uscan
 	./test_uscan_mangle
 	rm -rf uscan/gpg
@@ -17,6 +18,7 @@ test-installed:
 	./test_debchange --installed
 	./test_debdiff --installed
 	./test_licensecheck --installed
+	./test_licensecheck_SL --installed
 	./test_uscan --installed
 	./test_uscan_mangle --installed
 	rm -rf uscan/gpg
diff --git a/test/test_licensecheck_SL b/test/test_licensecheck_SL
new file mode 100755
index 0000000..da42ee3
--- /dev/null
+++ b/test/test_licensecheck_SL
@@ -0,0 +1,78 @@
+#!/usr/bin/perl 
+
+use File::Temp qw();
+use Software::License;
+require UNIVERSAL::require;
+use Test::More;
+
+my $COMMAND = ($ARGV[0] eq '--installed')
+            ? "licensecheck --no-conf"
+            : "../scripts/licensecheck.pl --no-conf";
+
+my %LICENSES = (
+    Apache_2_0=>'Apache (v2.0)',
+    FreeBSD=>'BSD (2 clause)',
+    GPL_1=>'GPL (v1)',
+    GPL_2=>'GPL (v2)',
+    GPL_3=>'GPL (v3)',
+    LGPL_2=>'LGPL (v2)',
+    LGPL_2_1=>'LGPL (v2.1)',
+    LGPL_3_0=>'LGPL (v3)',
+    MIT=>'MIT/X11 (BSD like)',
+    Mozilla_2_0=>'MPL (v2.0)',
+    QPL_1_0=>'QPL',
+    Zlib=>'zlib/libpng',
+    CC0_1_0=>'UNKNOWN',
+    GFDL_1_3=>'UNKNOWN',
+    Artistic_1_0=>'UNKNOWN',
+    Artistic_2_0=>'UNKNOWN',
+    Mozilla_1_0=>'UNKNOWN',
+    None=>'UNKNOWN',
+    PostgreSQL=>'UNKNOWN',
+    AGPL_3=>'UNKNOWN',
+    SSLeay=>'BSD (2 clause)',
+    Apache_1_1=>'UNKNOWN',
+    Mozilla_1_1=>'UNKNOWN',
+    GFDL_1_2=>'UNKNOWN',
+    Sun=>'UNKNOWN',
+    BSD=>'UNKNOWN',
+    OpenSSL=>'UNKNOWN',
+    Perl_5=>'UNKNOWN',
+);
+
+plan tests=>scalar(keys %LICENSES);
+
+my $dir = File::Temp->newdir('/tmp/slgenXXXXX');
+my $year = 2000;
+foreach my $license (keys %LICENSES) {
+	my $slfile = $dir->dirname . "/$license";
+	my $module = "Software::License::$license";
+	$module->require;
+	my $slobj = $module->new({
+		holder => 'Testophilus Testownik <tester at testity.org>',
+		year=>$year,
+	});
+	open my $fh, '>', $slfile;
+	print $fh $slobj->notice;
+	print $fh $slobj->debian_text;
+	close $fh;
+	++$year;
+}
+my $dirname=$dir->dirname;
+open(my $fh, "$COMMAND --recursive -c '.+' $dirname |") or die "can't run licensecheck: $!";
+while(my $line = <$fh>) {
+    if ($line =~ m{^$dirname/(\w+): (.+)$}) {
+        my $file=$1;
+        my $result=$2;
+        my $success = is($result, $LICENSES{$file}, $file);
+        if ($LICENSES{$file} eq 'UNKNOWN' and $success) {
+            diag("licensecheck failed to parse $file as expected");
+        }
+    }
+    else {
+        die "Unexpected output: $line";
+    }
+}
+
+    
+    

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list