Skip Menu |

This queue is for tickets about the Crypt-ECB CPAN distribution.

Report information
The Basics
Id: 82301
Status: resolved
Priority: 0/
Queue: Crypt-ECB

People
Owner: Nobody in particular
Requestors: Xavier (no email address)
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.45
Fixed in: (no value)



Subject: Use Test::More in your tests
Hi, I've written the joined patch to use Test::More in your tests, else cpantesters and other robots cannot check the results. It will be used in Debian packaging. Cheers, Xavier
Subject: use-standard-tests.patch
Description: Use standards tests Author: Xavier Guimard <x.guimard@free.fr> Bug: <url in upstream bugtracker> Forwarded: <no|not-needed|url proving that it has been forwarded> Last-Update: 2012-12-28 --- a/t/70-funcstyle.t +++ b/t/70-funcstyle.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB qw(encrypt decrypt PADDING_AUTO); +#use Crypt::ECB qw(encrypt decrypt PADDING_AUTO); my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>37; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB, qw(encrypt decrypt PADDING_AUTO)) }; my ($crypt, $cipher, $key, $ks, $len, $nok, $enc1, $enc2, $dec1, $dec2, $test); @@ -31,27 +35,25 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 3 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $key = substr($xkey, 0, $ks); $crypt->key($key); - $nok = 0; + #$nok = 0; $enc1 = $crypt->encrypt($text); $enc2 = encrypt($key, $cipher, $text, PADDING_AUTO); - $nok++ unless ($enc1 eq $enc2); + ok($enc1 eq $enc2); $dec1 = $crypt->decrypt($enc1); $dec2 = decrypt($key, $cipher, $enc2, PADDING_AUTO); - $nok++ unless ($dec1 eq $text); - $nok++ unless ($dec2 eq $text); + ok($dec1 eq $text); + ok($dec2 eq $text); - print "not " if $nok; - print "ok ".(++$test)."\n"; + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/65-nullblock-2.t +++ b/t/65-nullblock-2.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB; +#use Crypt::ECB; my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>13; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $len, $nok, $enc, $dec, $test); @@ -31,20 +35,18 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); - $nok = 0; + #$nok = 0; $enc = $crypt->encrypt($text); - $nok++ unless $crypt->decrypt($enc) eq $text; + ok($crypt->decrypt($enc) eq $text); - print "not " if $nok; - print "ok ".(++$test)."\n"; + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/40-substr.t +++ b/t/40-substr.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB; +#use Crypt::ECB; my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>13; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $len, $nok, $enc, $dec, $test); @@ -31,11 +35,8 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); @@ -47,6 +48,8 @@ $dec = $crypt->decrypt($enc); $nok++ unless substr($text,0,$len) eq $dec; } - print "not " if $nok; - print "ok ".(++$test)."\n"; + ok($nok == 0); + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/60-nullblock-1.t +++ b/t/60-nullblock-1.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB; +#use Crypt::ECB; my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>13; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $len, $nok, $enc, $dec, $test); @@ -31,20 +35,18 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); - $nok = 0; + #$nok = 0; $enc = $crypt->encrypt($text); - $nok++ unless $crypt->decrypt($enc) eq $text; + ok($crypt->decrypt($enc) eq $text); - print "not " if $nok; - print "ok ".(++$test)."\n"; + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/75-funcstyle-nullblock.t +++ b/t/75-funcstyle-nullblock.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB qw(encrypt decrypt PADDING_AUTO); +#use Crypt::ECB qw(encrypt decrypt PADDING_AUTO); my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>37; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB, qw(encrypt decrypt PADDING_AUTO)) }; my ($crypt, $cipher, $key, $ks, $len, $nok, $enc1, $enc2, $dec1, $dec2, $test); @@ -31,27 +35,25 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 3 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $key = substr($xkey, 0, $ks); $crypt->key($key); - $nok = 0; + #$nok = 0; $enc1 = $crypt->encrypt($text); $enc2 = encrypt($key, $cipher, $text, PADDING_AUTO); - $nok++ unless ($enc1 eq $enc2); + ok($enc1 eq $enc2); $dec1 = $crypt->decrypt($enc1); $dec2 = decrypt($key, $cipher, $enc2, PADDING_AUTO); - $nok++ unless ($dec1 eq $text); - $nok++ unless ($dec2 eq $text); + ok($dec1 eq $text); + ok($dec2 eq $text); - print "not " if $nok; - print "ok ".(++$test)."\n"; + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/30-padding.t +++ b/t/30-padding.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB; +#use Crypt::ECB; my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>25; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $len, $nok, $enc, $dec, $test); @@ -29,24 +33,24 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 2 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); - $nok = 0; + #$nok = 0; $crypt->padding(PADDING_AUTO); $enc = $crypt->encrypt($text); - $nok++ unless $crypt->decrypt($enc) eq $text; + ok($crypt->decrypt($enc) eq $text); + #$nok++ unless $crypt->decrypt($enc) eq $text; $crypt->padding(PADDING_NONE); - $nok++ unless $crypt->decrypt($enc) eq $text."\x02\x02"; + ok($crypt->decrypt($enc) eq $text."\x02\x02"); + #$nok++ unless $crypt->decrypt($enc) eq $text."\x02\x02"; - print "not " if $nok; - print "ok ".(++$test)."\n"; + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/10-encryption.t +++ b/t/10-encryption.t @@ -19,9 +19,11 @@ # 'Twofish2', '0958c674179aefaf13de8b25a613174dc40a90b80918bce55d314c86ecd3db45', ); -print "1..", scalar(keys %data), "\n"; +use Test::More tests=>12; -use Crypt::ECB; +#print "1..", scalar(keys %data), "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $enc, $test); @@ -34,16 +36,15 @@ foreach $cipher (sort keys %data) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); $enc = $crypt->encrypt_hex($text); - print "not " unless $enc eq $data{$cipher}; - print "ok ".(++$test)."\n"; + ok($enc eq $data{$cipher}); + #print "not " unless $enc eq $data{$cipher}; + #print "ok ".(++$test)."\n"; + } } --- a/t/50-caching.t +++ b/t/50-caching.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Crypt::ECB; +#use Crypt::ECB; my @ciphers = ( @@ -18,7 +18,11 @@ 'Twofish2', ); -print "1..", $#ciphers+1, "\n"; +use Test::More tests=>13; + +#print "1..", $#ciphers+1, "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $len, $nok, $enc, $dec, $test); @@ -31,11 +35,8 @@ foreach $cipher (@ciphers) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); @@ -54,6 +55,8 @@ $nok++ unless $text eq $dec; } - print "not " if $nok; - print "ok ".(++$test)."\n"; + ok($nok==0); + #print "not " if $nok; + #print "ok ".(++$test)."\n"; + } } --- a/t/20-decryption.t +++ b/t/20-decryption.t @@ -19,9 +19,11 @@ # 'Twofish2', '0958c674179aefaf13de8b25a613174dc40a90b80918bce55d314c86ecd3db45', ); -print "1..", scalar(keys %data), "\n"; +use Test::More tests=>12; -use Crypt::ECB; +#print "1..", scalar(keys %data), "\n"; + +BEGIN { use_ok (Crypt::ECB) }; my ($crypt, $cipher, $ks, $dec, $test); @@ -34,16 +36,15 @@ foreach $cipher (sort keys %data) { - unless ($crypt->cipher($cipher)) - { - print "ok ".(++$test)." # skip, $cipher not installed\n"; - next; - } + SKIP: { + skip "$cipher not installed", 1 unless($crypt->cipher($cipher)); $ks = ($crypt->{Keysize} or 8); $crypt->key(substr($key,0,$ks)); $dec = $crypt->decrypt_hex($data{$cipher}); - print "not " unless $dec eq $text; - print "ok ".(++$test)."\n"; + ok($dec eq $text); + #print "not " unless $dec eq $text; + #print "ok ".(++$test)."\n"; + } }