summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/00signature.t92
-rw-r--r--t/42.gzbin0 -> 26 bytes
-rw-r--r--t/431
-rw-r--r--t/44.bz2bin0 -> 39 bytes
-rw-r--r--t/52podcover.t14
-rw-r--r--t/CHECKSUMS49
-rw-r--r--t/pod.t6
-rw-r--r--t/updatedir.t65
8 files changed, 227 insertions, 0 deletions
diff --git a/t/00signature.t b/t/00signature.t
new file mode 100644
index 0000000..35fc928
--- /dev/null
+++ b/t/00signature.t
@@ -0,0 +1,92 @@
+# -*- mode: cperl -*-
+
+use strict;
+BEGIN {
+ sub find_exe {
+ my($exe,$path) = @_;
+ my($dir);
+ #warn "in find_exe exe[$exe] path[@$path]";
+ for $dir (@$path) {
+ my $abs = File::Spec->catfile($dir,$exe);
+ require ExtUtils::MakeMaker;
+ if (($abs = MM->maybe_command($abs))) {
+ return $abs;
+ }
+ }
+ }
+ my $found_prereq = 0;
+ unless ($found_prereq) {
+ $found_prereq = eval { require Digest::SHA; 1 };
+ }
+ unless ($found_prereq) {
+ $found_prereq = eval { require Digest::SHA1; 1 };
+ }
+ unless ($found_prereq) {
+ $found_prereq = eval { require Digest::SHA::PurePerl; 1 };
+ }
+ my $exit_message = "";
+ unless ($found_prereq) {
+ $exit_message = "None of the supported SHA modules (Digest::SHA,Digest::SHA1,Digest::SHA::PurePerl) found";
+ }
+ unless ($exit_message) {
+ if (!-f 'SIGNATURE') {
+ $exit_message = "No signature file";
+ }
+ }
+ unless ($exit_message) {
+ if (!-s 'SIGNATURE') {
+ $exit_message = "Empty signature file";
+ }
+ }
+ unless ($exit_message) {
+ if (eval { require Module::Signature; 1 }) {
+ my $min = "0.66";
+ if ($Module::Signature::VERSION < $min-0.0000001) {
+ $exit_message = "Signature testing disabled for Module::Signature versions < $min";
+ }
+ } else {
+ $exit_message = "No Module::Signature found [INC = @INC]";
+ }
+ }
+ unless ($exit_message) {
+ if (!eval {
+ use Socket qw(AF_INET SOCK_STREAM pack_sockaddr_in inet_aton);
+ my $socket;
+ socket($socket, AF_INET, SOCK_STREAM, 0) and
+ connect(
+ $socket,
+ pack_sockaddr_in(
+ scalar getservbyname('hkp', 'tcp'),
+ inet_aton('pool.sks-keyservers.net')
+ )
+ ) and
+ close($socket)
+ }) {
+ $exit_message = "Cannot connect to the keyserver";
+ }
+ }
+ unless ($exit_message) {
+ require Config;
+ my(@path) = split /$Config::Config{'path_sep'}/, $ENV{'PATH'};
+ if (!find_exe('gpg',\@path)) {
+ $exit_message = "Signature testing disabled without gpg program available";
+ }
+ }
+ if ($exit_message) {
+ $|=1;
+ print "1..0 # SKIP $exit_message\n";
+ eval "require POSIX; 1" and POSIX::_exit(0);
+ }
+}
+
+print "1..1\n";
+
+$ENV{TEST_SIGNATURE} = 1;
+(Module::Signature::verify() == Module::Signature::SIGNATURE_OK())
+ or print "not ";
+print "ok 1 # Valid signature\n";
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# End:
diff --git a/t/42.gz b/t/42.gz
new file mode 100644
index 0000000..eeb3e52
--- /dev/null
+++ b/t/42.gz
Binary files differ
diff --git a/t/43 b/t/43
new file mode 100644
index 0000000..920a139
--- /dev/null
+++ b/t/43
@@ -0,0 +1 @@
+43
diff --git a/t/44.bz2 b/t/44.bz2
new file mode 100644
index 0000000..47e44fa
--- /dev/null
+++ b/t/44.bz2
Binary files differ
diff --git a/t/52podcover.t b/t/52podcover.t
new file mode 100644
index 0000000..48b82ff
--- /dev/null
+++ b/t/52podcover.t
@@ -0,0 +1,14 @@
+# -*- mode: cperl -*-
+use Test::More;
+eval "use 5.00504";
+plan skip_all => "perl 5.00504 required for this test" if $@;
+eval "use Test::Pod::Coverage 0.18"; # 0.15 was misbehaving according to David Cantrell
+plan skip_all => "Test::Pod::Coverage 0.18 required for testing pod coverage" if $@;
+plan tests => 1;
+my $trustme = { trustme => [ qw{
+ ckcmp
+ investigate
+ makehashref
+ }]
+ };
+pod_coverage_ok( "CPAN::Checksums", $trustme );
diff --git a/t/CHECKSUMS b/t/CHECKSUMS
new file mode 100644
index 0000000..24b4b43
--- /dev/null
+++ b/t/CHECKSUMS
@@ -0,0 +1,49 @@
+# CHECKSUMS file written on Sat Nov 20 22:14:24 2010 GMT by CPAN::Checksums (v2.07)
+$cksum = {
+ '00signature.t' => {
+ 'md5' => '55d2528e0129b0c32bc51bf287f2ac01',
+ 'mtime' => '2010-11-20',
+ 'sha256' => 'f429ad014eb27261603740854130e696bd106a087f0f92086b2862a3af6dcaf4',
+ 'size' => 2344
+ },
+ '42.gz' => {
+ 'md5' => '915cdde7181ab542763969e063b7a9a9',
+ 'md5-ungz' => '50a2fabfdd276f573ff97ace8b11c5f4',
+ 'mtime' => '2005-10-30',
+ 'sha256' => '787e758a975d04560f6a9d4671646a48c4e9da4f40d4e102bc4562cd15c71ab5',
+ 'sha256-ungz' => '084c799cd551dd1d8d5c5f9a5d593b2e931f5e36122ee5c793c1d08a19839cc0',
+ 'size' => 26
+ },
+ '43' => {
+ 'md5' => 'f0287f33eba7192e2a9c6a14f829aa1a',
+ 'mtime' => '2010-11-20',
+ 'sha256' => '0e55092af0746630c98d1b2e0d960617c33f8ea7b55739fd18cb7cd5342a28ca',
+ 'size' => 3
+ },
+ '44.bz2' => {
+ 'md5' => 'b3c551bfbf1d15ce93b47346a11cc87a',
+ 'md5-unbz2' => 'e760668b6273d38c832c153fde5725da',
+ 'mtime' => '2005-10-30',
+ 'sha256' => '09f646275a0b0622418ed364affe3c2df7dbb02c01862d84d7d06e6b6605c790',
+ 'sha256-unbz2' => 'b1ce0aa6fdf3cf349d773243dab9fbbe09d30619f38b0c1e8977e28c4f0bc495',
+ 'size' => 39
+ },
+ '52podcover.t' => {
+ 'md5' => '9845f6c5f049d637c92ae34e67328c77',
+ 'mtime' => '2007-08-05',
+ 'sha256' => '558d9083fe9dfa6aa66806caf4545bee35f2cac36592627aeed3b8cf0ca4fdf2',
+ 'size' => 567
+ },
+ 'pod.t' => {
+ 'md5' => '45b17e11a9736a0c485f861f95f063b9',
+ 'mtime' => '2005-12-15',
+ 'sha256' => '6109dadab614d170fc3db10b00a4c41c221860b1b1085a54af9a5f9f52480494',
+ 'size' => 152
+ },
+ 'updatedir.t' => {
+ 'md5' => 'b2dad83957b2786005860303866548c0',
+ 'mtime' => '2010-01-23',
+ 'sha256' => '583d24e7cbbf77a61b56ccced45b6f5b17844d0c8146f652fc92e2380ca63cc7',
+ 'size' => 1808
+ }
+};
diff --git a/t/pod.t b/t/pod.t
new file mode 100644
index 0000000..105953b
--- /dev/null
+++ b/t/pod.t
@@ -0,0 +1,6 @@
+# -*- mode: cperl -*-
+
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();
diff --git a/t/updatedir.t b/t/updatedir.t
new file mode 100644
index 0000000..6ee0311
--- /dev/null
+++ b/t/updatedir.t
@@ -0,0 +1,65 @@
+# -*- Mode: cperl; cperl-indent-level: 4 -*-
+
+# Before `make install' is performed this script should be runnable with
+# `make test'.
+
+use File::Path qw(mkpath rmtree);
+use File::Spec;
+use Test::More;
+my $HAVE_TIME_HIRES = 0;
+
+sub _f ($) {File::Spec->catfile(split /\//, shift);}
+sub _d ($) {File::Spec->catdir(split /\//, shift);}
+
+my $plan = 21;
+if (eval { require Time::HiRes; 1; }) {
+ $HAVE_TIME_HIRES = 1;
+}
+plan tests => $plan;
+
+use_ok("CPAN::Checksums");
+my $ret = CPAN::Checksums::updatedir("t");
+ok($ret >= 1, "ret[$ret]");
+
+my $warn;
+{
+ chmod 0644, _f"t/43";
+ local *F;
+ open F, ">", _f"t/43" or die;
+ print F "4321\n" x 1_000_000;
+ close F;
+ local $CPAN::Checksums::CAUTION;
+ $CPAN::Checksums::CAUTION=1;
+ $SIG{__WARN__} = sub { $warn = shift; };
+ $ret = CPAN::Checksums::updatedir("t");
+ is($ret,2,"changed once");
+
+ like($warn,qr/^differing old\/new/m,"warning emitted");
+
+ my $start = $HAVE_TIME_HIRES ? Time::HiRes::time() : time;
+ $ret = CPAN::Checksums::updatedir("t");
+ my $tooktime = ($HAVE_TIME_HIRES ? Time::HiRes::time() : time) - $start;
+ is($ret,1,"no change tooktime[$tooktime]");
+
+ open F, ">", _f"t/43";
+ print F "43\n";
+ close F;
+ $warn="";
+}
+
+$ret = CPAN::Checksums::updatedir("t");
+is($ret,2,"changed again");
+is($warn,"","no warning");
+my @stat = stat _f"t/CHECKSUMS";
+sleep 2;
+$ret = CPAN::Checksums::updatedir("t");
+is($ret,1,"no change");
+my @stat2 = stat _f"t/CHECKSUMS";
+for my $s (0..7,9..11) { # 8==atime not our business; 12==blocks may magically change
+ is($stat[$s],$stat2[$s],"unchanged stat element $s");
+}
+mkpath _d"t/emptydir";
+$ret = CPAN::Checksums::updatedir(_d"t/emptydir");
+is($ret,2,"empty dir gives also 2");
+ok(-f _f"t/emptydir/CHECKSUMS", "found the checksums file");
+rmtree _d"t/emptydir";