From 2d048f4fc1980f3488db5c8a7cdc9c536e1354db Mon Sep 17 00:00:00 2001 From: Brad Gilbert Date: Sat, 18 Apr 2009 22:41:05 -0500 Subject: [PATCH] Added POD tests and a Perl::Critic test Also worked on removing failures of those tests --- perl/README | 11 ++-- perl/lib/Nasm/Regs.pm | 10 ++- perl/lib/Nasm/Regs/Format.pm | 15 ++++- perl/lib/Nasm/Regs/Format/C.pm | 10 ++- perl/lib/Nasm/Regs/Format/DC.pm | 10 ++- perl/lib/Nasm/Regs/Format/DH.pm | 10 ++- perl/lib/Nasm/Regs/Format/FC.pm | 10 ++- perl/lib/Nasm/Regs/Format/H.pm | 10 ++- perl/lib/Nasm/Regs/Format/ORDER.pm | 10 ++- perl/lib/Nasm/Regs/Format/VC.pm | 10 ++- perl/lib/Nasm/Regs/Format/YAML.pm | 10 ++- perl/lib/Nasm/Regs/Register.pm | 11 +++- perl/lib/Nasm/Utils.pm | 12 +++- perl/lib/Nasm/crc64.pm | 29 ++++++--- perl/lib/Nasm/insns.pm | 6 ++ perl/lib/Nasm/insns/Flags.pm | 15 +++++ perl/lib/Nasm/insns/Operands.pm | 19 ++++++ perl/lib/phash.pm | 122 ++++++++++++++++++++++--------------- perl/lib/random_sv_vectors.pm | 7 +++ perl/t/perl-critic.t | 35 +++++++++++ perl/t/pod-coverage.t | 38 ++++++++++++ perl/t/pod.t | 29 +++++---- perl/t/version/h.t | 4 +- perl/t/version/json.t | 3 +- perl/t/version/mac.t | 5 +- perl/t/version/make.t | 5 +- perl/t/version/nsis.t | 4 +- perl/t/version/perl.t | 3 +- perl/t/version/pod.t | 38 ++++++++++++ perl/t/version/sed.t | 4 +- perl/t/version/simple.t | 3 +- perl/t/version/yaml.t | 3 +- perl/version.pl | 27 ++++---- 33 files changed, 403 insertions(+), 135 deletions(-) create mode 100644 perl/t/perl-critic.t create mode 100644 perl/t/pod-coverage.t create mode 100644 perl/t/version/pod.t diff --git a/perl/README b/perl/README index a2b4a987..1638bcab 100644 --- a/perl/README +++ b/perl/README @@ -2,14 +2,17 @@ cd perl; prove; to run all tests: -env RELEASE_TESTING=1 prove; + env RELEASE_TESTING=1 prove; + +to only run normal + pod tests: + env POD_TESTING=1 prove; Finished / Usable -version.pl -regs.pl + version.pl + regs.pl Incomplete -insns.pl + insns.pl version.pl has good test coverage diff --git a/perl/lib/Nasm/Regs.pm b/perl/lib/Nasm/Regs.pm index 119300ef..dd830a3f 100644 --- a/perl/lib/Nasm/Regs.pm +++ b/perl/lib/Nasm/Regs.pm @@ -1,3 +1,9 @@ +=head1 NAME + +Nasm::Regs + +=cut + package Nasm::Regs; use strict; use warnings; @@ -115,7 +121,9 @@ sub Register{ } sub DisassemblerClasses{ my($self) = @_; - return sort keys %{$self->{disassembler}}; + my @return = sort keys %{$self->{disassembler}}; + return @return if wantarray; + return \@return; } sub DisassemblerClass{ my($self,$class) = @_; diff --git a/perl/lib/Nasm/Regs/Format.pm b/perl/lib/Nasm/Regs/Format.pm index d95ec1b7..978821ce 100644 --- a/perl/lib/Nasm/Regs/Format.pm +++ b/perl/lib/Nasm/Regs/Format.pm @@ -1,16 +1,27 @@ +=head1 NAME + +Nasm::Regs::Format + +=cut + +package Nasm::Regs::Format; use strict; use warnings; -package Nasm::Regs::Format; #our @list = qw'h c fc vc dc dh'; +=head2 format + +=cut sub format{ my($regs,$fmt) = @_; + ## no critic no strict 'refs'; my $package = __PACKAGE__.'::'.uc($fmt); eval "require $package;"; + ## use critic if($@){ die qq[Failed to load format "$fmt"\n]; } @@ -18,7 +29,7 @@ sub format{ my $return; eval{ - $return = *{$package.'::format'}{CODE}->($regs); + $return = *{$package.'::_format'}{CODE}->($regs); }; if($@){ die qq[Problem with format plugin "$fmt":\n\t$@]; diff --git a/perl/lib/Nasm/Regs/Format/C.pm b/perl/lib/Nasm/Regs/Format/C.pm index 5967a36e..0926bca6 100644 --- a/perl/lib/Nasm/Regs/Format/C.pm +++ b/perl/lib/Nasm/Regs/Format/C.pm @@ -1,8 +1,14 @@ +=head1 NAME + +Nasm::Regs::Format::C + +=cut + +package Nasm::Regs::Format::C; use strict; use warnings; -package Nasm::Regs::Format::C; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; diff --git a/perl/lib/Nasm/Regs/Format/DC.pm b/perl/lib/Nasm/Regs/Format/DC.pm index 4640acca..51af7bf5 100644 --- a/perl/lib/Nasm/Regs/Format/DC.pm +++ b/perl/lib/Nasm/Regs/Format/DC.pm @@ -1,8 +1,14 @@ +=head1 NAME + +Nasm::Regs::Format::DC + +=cut + +package Nasm::Regs::Format::DC; use strict; use warnings; -package Nasm::Regs::Format::DC; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; diff --git a/perl/lib/Nasm/Regs/Format/DH.pm b/perl/lib/Nasm/Regs/Format/DH.pm index d636a1c9..7c0f6257 100644 --- a/perl/lib/Nasm/Regs/Format/DH.pm +++ b/perl/lib/Nasm/Regs/Format/DH.pm @@ -1,8 +1,14 @@ +=head1 NAME + +Nasm::Regs::Format::DH + +=cut + +package Nasm::Regs::Format::DH; use strict; use warnings; -package Nasm::Regs::Format::DH; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; diff --git a/perl/lib/Nasm/Regs/Format/FC.pm b/perl/lib/Nasm/Regs/Format/FC.pm index 38d76e82..c99106b2 100644 --- a/perl/lib/Nasm/Regs/Format/FC.pm +++ b/perl/lib/Nasm/Regs/Format/FC.pm @@ -1,8 +1,14 @@ +=head1 NAME + +Nasm::Regs::Format::FC + +=cut + +package Nasm::Regs::Format::FC; use strict; use warnings; -package Nasm::Regs::Format::FC; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; diff --git a/perl/lib/Nasm/Regs/Format/H.pm b/perl/lib/Nasm/Regs/Format/H.pm index 3920a7c9..97edf300 100644 --- a/perl/lib/Nasm/Regs/Format/H.pm +++ b/perl/lib/Nasm/Regs/Format/H.pm @@ -1,9 +1,15 @@ +=head1 NAME + +Nasm::Regs::Format::H + +=cut + +package Nasm::Regs::Format::H; use strict; use warnings; -package Nasm::Regs::Format::H; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; my $out = <RegisterNames; diff --git a/perl/lib/Nasm/Regs/Format/VC.pm b/perl/lib/Nasm/Regs/Format/VC.pm index 8ef05141..eeabe40c 100644 --- a/perl/lib/Nasm/Regs/Format/VC.pm +++ b/perl/lib/Nasm/Regs/Format/VC.pm @@ -1,8 +1,14 @@ +=head1 NAME + +Nasm::Regs::Format::VC + +=cut + +package Nasm::Regs::Format::VC; use strict; use warnings; -package Nasm::Regs::Format::VC; -sub format{ +sub _format{ my($regs) = @_; my $filename = $regs->filename; diff --git a/perl/lib/Nasm/Regs/Format/YAML.pm b/perl/lib/Nasm/Regs/Format/YAML.pm index 6c6efb21..afdc1006 100644 --- a/perl/lib/Nasm/Regs/Format/YAML.pm +++ b/perl/lib/Nasm/Regs/Format/YAML.pm @@ -1,10 +1,16 @@ +=head1 NAME + +Nasm::Regs::Format::YAML + +=cut + +package Nasm::Regs::Format::YAML; use strict; use warnings; -package Nasm::Regs::Format::YAML; use YAML::XS; -sub format{ +sub _format{ my($regs) = @_; my @names = $regs->RegisterNames; diff --git a/perl/lib/Nasm/Regs/Register.pm b/perl/lib/Nasm/Regs/Register.pm index 04ee8814..24a73c26 100644 --- a/perl/lib/Nasm/Regs/Register.pm +++ b/perl/lib/Nasm/Regs/Register.pm @@ -1,7 +1,12 @@ -use strict; -use warnings; +=head1 NAME + +Nasm::Regs::Register + +=cut package Nasm::Regs::Register; +use strict; +use warnings; sub new{ my($class,@v) = @_; @@ -13,6 +18,7 @@ sub new{ } BEGIN{ + ## no critic my $i = -1; for my $sub_name(qw'RegisterName AssemblerClass',undef,'x86RegisterNumber'){ no strict 'refs'; @@ -24,6 +30,7 @@ BEGIN{ return $self->[$i]; } } + ## use critic } sub DisassemberClasses{ diff --git a/perl/lib/Nasm/Utils.pm b/perl/lib/Nasm/Utils.pm index a2723f41..a7900e53 100644 --- a/perl/lib/Nasm/Utils.pm +++ b/perl/lib/Nasm/Utils.pm @@ -1,6 +1,12 @@ +=head1 NAME + +Nasm::Regs::Register + +=cut + +package Nasm::Utils; use strict; use warnings; -package Nasm::Utils; use base 'Exporter'; @@ -11,14 +17,14 @@ our @EXPORT_OK = qw{ # Turn a numeric list into a hex string -sub str2hex(@){ +sub str2hex{ my @return = map {sprintf("%02X", $_)} @_; return @return if wantarray; return join '', @return; } -sub addprefix ($@) { +sub addprefix{ my ($prefix, @list) = @_; my @return = map { sprintf("%s%02X", $prefix, $_) diff --git a/perl/lib/Nasm/crc64.pm b/perl/lib/Nasm/crc64.pm index 4196cba6..2a37c6fb 100644 --- a/perl/lib/Nasm/crc64.pm +++ b/perl/lib/Nasm/crc64.pm @@ -1,3 +1,18 @@ +=head1 NAME + +Nasm::crc64 + +=head1 DESCRIPTION + +Pure Perl implementation of the same CRC64 implementation used +elsewhere in NASM. + +Note: Perl may have 32- or 64-bit integers; we need to handle both +without overflowing into floating point (yuck), so handle them as +pairs of 32-bit numbers. Ordering is BIGENDIAN. + +=cut + package Nasm::crc64; use warnings; use strict; @@ -6,15 +21,6 @@ require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(crc64); -# -*- perl -*- -# -# Pure Perl implementation of the same CRC64 implementation used -# elsewhere in NASM. -# -# Note: Perl may have 32- or 64-bit integers; we need to handle both -# without overflowing into floating point (yuck), so handle them as -# pairs of 32-bit numbers. Ordering is BIGENDIAN. -# our @crc64_tab = ( [0x00000000, 0x00000000], [0x7ad870c8, 0x30358979], @@ -147,7 +153,12 @@ our @crc64_tab = ( [0x536fa08f, 0xdfd90e51], [0x29b7d047, 0xefec8728] ); +=head2 crc64( @cv, $str ) + +=cut +## no critic sub crc64(\@$) { + ## use critic my ($cv, $str) = @_; my @cc = @$cv; $cc[0] %= 4294967296; diff --git a/perl/lib/Nasm/insns.pm b/perl/lib/Nasm/insns.pm index 563b4fca..3d0fe652 100644 --- a/perl/lib/Nasm/insns.pm +++ b/perl/lib/Nasm/insns.pm @@ -1,3 +1,9 @@ +=head1 NAME + +Nasm::insns + +=cut + package Nasm::insns; use strict; use warnings; diff --git a/perl/lib/Nasm/insns/Flags.pm b/perl/lib/Nasm/insns/Flags.pm index fa8ca5c6..0da554bf 100644 --- a/perl/lib/Nasm/insns/Flags.pm +++ b/perl/lib/Nasm/insns/Flags.pm @@ -1,3 +1,9 @@ +=head1 NAME + +Nasm::insns::Flags + +=cut + package Nasm::insns::Flags; use strict; use warnings; @@ -18,7 +24,9 @@ our( %map2id, %also_enable, @arch); { my @yaml_streams; { + ## no critic open( my $data, '<&DATA' ) or die; + ## use critic seek( $data, 0, 0 ); { @@ -45,8 +53,10 @@ our( %map2id, %also_enable, @arch); $variable_name =~ s/^([%@\$])//; my $type = $1; + ## no critic no strict qw'refs'; no warnings qw'once'; + ## use critic # load on demand my $ref = Load $yaml_streams[$index] or @@ -84,6 +94,11 @@ our( %map2id, %also_enable, @arch); +=head2 new + +Creates a new Nasm::insns::Flags object + +=cut sub new{ my( $class, $string ) = @_; diff --git a/perl/lib/Nasm/insns/Operands.pm b/perl/lib/Nasm/insns/Operands.pm index 0b3e8806..887c87bc 100644 --- a/perl/lib/Nasm/insns/Operands.pm +++ b/perl/lib/Nasm/insns/Operands.pm @@ -1,8 +1,20 @@ +=head1 NAME + +Nasm::insns::Operands + +=cut + package Nasm::insns::Operands; use strict; use warnings; use Scalar::Util 'reftype'; +=head2 new + +Creates a new Nasm::insns::Operands object + +=cut + sub new{ my( $class, $string ) = @_; $string =~ s/^ \s+ //gx; @@ -23,6 +35,13 @@ sub new{ return $self; } + +=head2 string + +Stringifys an Nasm::insns::Operands object + +=cut + sub string{ my( $self ) = @_; diff --git a/perl/lib/phash.pm b/perl/lib/phash.pm index 8c553c0c..e86b89ab 100644 --- a/perl/lib/phash.pm +++ b/perl/lib/phash.pm @@ -1,10 +1,17 @@ -# -*- perl -*- -# -# Perfect Minimal Hash Generator written in Perl, which produces -# C output. -# -# Requires the CPAN Graph module (tested against 0.81, 0.83, 0.84) -# +=head1 NAME + +phash + +=head1 DESCRIPTION + +Perfect Minimal Hash Generator written in Perl, which produces +C output. + +Requires the CPAN Graph module (tested against 0.81, 0.83, 0.84) + + +=cut + package phash; use strict; use warnings; @@ -24,33 +31,41 @@ our @EXPORT = qw{ }; +## no critic sub prehash($$\@); sub walk_graph(\@\@$$); sub gen_hash_n($\@\%$); sub gen_perfect_hash(\%); sub read_input(); sub verify_hash_table(\%\@); +## use critic + +=head2 prehash( $key, $N, @sv ) + +Compute the prehash for a key -# -# Compute the prehash for a key -# -# prehash(key, N, sv) -# +=cut +## no critic sub prehash($$\@) { - my($key, $n, $sv) = @_; - my @c = crc64(@$sv, $key); + ## use critic + my($key, $n, $sv) = @_; + my @c = crc64(@$sv, $key); - # Create a bipartite graph... - my $low_word = (($c[1] & ($n-1)) << 1) + 0; # low word - my $high_word = (($c[0] & ($n-1)) << 1) + 1; # high word + # Create a bipartite graph... + my $low_word = (($c[1] & ($n-1)) << 1) + 0; # low word + my $high_word = (($c[0] & ($n-1)) << 1) + 1; # high word - return ($low_word, $high_word); + return ($low_word, $high_word); } -# -# Walk the assignment graph, return true on success -# +=head2 walk_graph( @node_val, @node_neighbor, $n, $v ) + +Walk the assignment graph, return true on success + +=cut +## no critic sub walk_graph(\@\@$$) { + ## use critic my($node_val,$node_neighbor,$n,$v) = @_; # print STDERR "Vertex $n value $v\n"; @@ -77,22 +92,22 @@ sub walk_graph(\@\@$$) { return 1; } -# -# Generate the function assuming a given N. -# -# gen_hash_n(N, sv, \%data, run) -# +=head2 gen_hash_n( $N, @sv, %data, $run ) + +Generate the function assuming a given N. + +=cut +## no critic sub gen_hash_n($\@\%$) { - my($n, $sv, $href, $run) = @_; - my @keys = keys(%{$href}); - my $i; - my $gr; - my $gsize = 2*$n; - my @node_val; - my @node_neighbor; - my %edges; - - for ($i = 0; $i < $gsize; $i++) { + ## use critic + my($n, $sv, $href, $run) = @_; + my @keys = keys(%{$href}); + my $gsize = 2*$n; + my @node_val; + my @node_neighbor; + my %edges; + + for( my $i = 0; $i < $gsize; $i++ ){ $node_neighbor[$i] = []; } @@ -126,7 +141,7 @@ sub gen_hash_n($\@\%$) { # sitation, the graph was cyclic. @node_val = (undef) x $gsize; - for ($i = 0; $i < $gsize; $i++) { + for( my $i = 0; $i < $gsize; $i++ ){ if (scalar(@{$node_neighbor[$i]})) { # This vertex has neighbors (is used) if (!defined($node_val[$i])) { @@ -153,12 +168,14 @@ sub gen_hash_n($\@\%$) { return ($n, $sv, \@node_val); } -# -# Driver for generating the function -# -# gen_perfect_hash(\%data) -# +=head2 gen_perfect_hash( %data ) + +Driver for generating the function + +=cut +## no critic sub gen_perfect_hash(\%) { + ## use critic my($href) = @_; my @keys = keys(%{$href}); #my @hashinfo; @@ -196,9 +213,11 @@ sub gen_perfect_hash(\%) { return; } -# -# Read input file -# +=head2 read_input + +Read input file + +=cut sub read_input() { my %out; my $x = 0; @@ -219,16 +238,19 @@ sub read_input() { return \%out; } -# -# Verify that the hash table is actually correct... -# +=head2 verify_hash_table( %href, @hashinfo ) + +Verify that the hash table is actually correct... + +=cut +## no critic sub verify_hash_table(\%\@){ + ## use critic my ($href, $hashinfo) = @_; my ($n, $sv, $g) = @{$hashinfo}; - my $k; my $err = 0; - foreach $k (keys(%$href)) { + for my $k (keys(%$href)) { my ($pf1, $pf2) = prehash($k, $n, @$sv); my $g1 = ${$g}[$pf1]; my $g2 = ${$g}[$pf2]; diff --git a/perl/lib/random_sv_vectors.pm b/perl/lib/random_sv_vectors.pm index 6d7a3ddb..8782e55c 100644 --- a/perl/lib/random_sv_vectors.pm +++ b/perl/lib/random_sv_vectors.pm @@ -5,6 +5,13 @@ use strict; use base 'Exporter'; our @EXPORT = qw(@random_sv_vectors); + +=head1 random_sv_vectors + +A list of randomized sv vectors + +=cut + our @random_sv_vectors = ( [0x076259c3, 0xe291c26c], [0xaee7ac5c, 0xcabdec91], [0x5d3862fb, 0x2e8a3060], [0x6fb3635c, 0x4783593a], diff --git a/perl/t/perl-critic.t b/perl/t/perl-critic.t new file mode 100644 index 00000000..e58a2163 --- /dev/null +++ b/perl/t/perl-critic.t @@ -0,0 +1,35 @@ +#!/usr/bin/env perl + +# Test that the syntax of our POD documentation is valid +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +my @MODULES = ( + 'Test::Perl::Critic' +); + +# Don't run tests during end-user installs +use Test::More; +unless ( + $ENV{RELEASE_TESTING} or + $ENV{AUTHOR_TESTING} +){ + plan( skip_all => "Author tests not required for installation" ); +} + +# Load the testing modules +foreach my $MODULE ( @MODULES ) { + eval "use $MODULE;"; + if ( $@ ) { + $ENV{RELEASE_TESTING} + ? die( "Failed to load required release-testing module $MODULE" ) + : plan( skip_all => "$MODULE not available for testing" ); + } +} + +all_critic_ok(); + +1; diff --git a/perl/t/pod-coverage.t b/perl/t/pod-coverage.t new file mode 100644 index 00000000..19614c66 --- /dev/null +++ b/perl/t/pod-coverage.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +# Test that the syntax of our POD documentation is valid +use strict; +use lib 'lib'; +BEGIN { + $| = 1; + $^W = 1; +} + +my @MODULES = ( + 'Test::Pod::Coverage' +); + +# Don't run tests during end-user installs +use Test::More; +unless( + $ENV{AUTOMATED_TESTING} or + $ENV{RELEASE_TESTING} or + $ENV{POD_TESTING} or + $ENV{AUTHOR_TESTING} +){ + plan( skip_all => "Author tests not required for installation" ); +} + +# Load the testing modules +foreach my $MODULE ( @MODULES ) { + eval "use $MODULE"; + if ( $@ ) { + $ENV{RELEASE_TESTING} + ? die( "Failed to load required release-testing module $MODULE" ) + : plan( skip_all => "$MODULE not available for testing" ); + } +} + +all_pod_coverage_ok(); + +1; diff --git a/perl/t/pod.t b/perl/t/pod.t index 9487c4d2..63321317 100644 --- a/perl/t/pod.t +++ b/perl/t/pod.t @@ -3,29 +3,34 @@ # Test that the syntax of our POD documentation is valid use strict; BEGIN { - $| = 1; - $^W = 1; + $| = 1; + $^W = 1; } my @MODULES = ( - 'Pod::Simple 3.07', - 'Test::Pod 1.26', + 'Pod::Simple 3.07', + 'Test::Pod 1.26', ); # Don't run tests during end-user installs use Test::More; -unless ( $ENV{AUTOMATED_TESTING} or $ENV{RELEASE_TESTING} ) { - plan( skip_all => "Author tests not required for installation" ); +unless( + $ENV{AUTOMATED_TESTING} or + $ENV{RELEASE_TESTING} or + $ENV{POD_TESTING} or + $ENV{AUTHOR_TESTING} +){ + plan( skip_all => "Author tests not required for installation" ); } # Load the testing modules foreach my $MODULE ( @MODULES ) { - eval "use $MODULE"; - if ( $@ ) { - $ENV{RELEASE_TESTING} - ? die( "Failed to load required release-testing module $MODULE" ) - : plan( skip_all => "$MODULE not available for testing" ); - } + eval "use $MODULE"; + if ( $@ ) { + $ENV{RELEASE_TESTING} + ? die( "Failed to load required release-testing module $MODULE" ) + : plan( skip_all => "$MODULE not available for testing" ); + } } all_pod_files_ok(); diff --git a/perl/t/version/h.t b/perl/t/version/h.t index 4edc8483..9d0c088c 100644 --- a/perl/t/version/h.t +++ b/perl/t/version/h.t @@ -13,9 +13,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; - +plan( tests => scalar keys %test ); my %map = ( diff --git a/perl/t/version/json.t b/perl/t/version/json.t index af32a92a..48cc7fe0 100644 --- a/perl/t/version/json.t +++ b/perl/t/version/json.t @@ -12,8 +12,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; +plan( tests => scalar keys %test ); for my $test ( sort keys %test ){ diff --git a/perl/t/version/mac.t b/perl/t/version/mac.t index fee5ae13..1352c362 100644 --- a/perl/t/version/mac.t +++ b/perl/t/version/mac.t @@ -18,10 +18,7 @@ our %test = load( use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; - - +plan( tests => scalar keys %test ); my %map = ( diff --git a/perl/t/version/make.t b/perl/t/version/make.t index 0b73edf9..1a2ea47c 100644 --- a/perl/t/version/make.t +++ b/perl/t/version/make.t @@ -11,10 +11,7 @@ our %test = load( use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; - - +plan( tests => scalar keys %test ); my %map = ( diff --git a/perl/t/version/nsis.t b/perl/t/version/nsis.t index 38402431..ff41e2a7 100644 --- a/perl/t/version/nsis.t +++ b/perl/t/version/nsis.t @@ -13,9 +13,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; - +plan( tests => scalar keys %test ); my %map = ( diff --git a/perl/t/version/perl.t b/perl/t/version/perl.t index ff2286a9..36c8f386 100644 --- a/perl/t/version/perl.t +++ b/perl/t/version/perl.t @@ -10,8 +10,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; +plan( tests => scalar keys %test ); for my $test ( sort keys %test ){ diff --git a/perl/t/version/pod.t b/perl/t/version/pod.t new file mode 100644 index 00000000..0a5f7c74 --- /dev/null +++ b/perl/t/version/pod.t @@ -0,0 +1,38 @@ +#!/usr/bin/env perl + +# Test that the syntax of our POD documentation is valid +use strict; +BEGIN { + $| = 1; + $^W = 1; +} + +my @MODULES = ( + 'Pod::Simple 3.07', + 'Test::Pod 1.26', +); + +# Don't run tests during end-user installs +use Test::More; +unless( + $ENV{AUTOMATED_TESTING} or + $ENV{RELEASE_TESTING} or + $ENV{POD_TESTING} or + $ENV{AUTHOR_TESTING} +){ + plan( skip_all => "Author tests not required for installation" ); +} + +# Load the testing modules +foreach my $MODULE ( @MODULES ) { + eval "use $MODULE"; + if ( $@ ) { + $ENV{RELEASE_TESTING} + ? die( "Failed to load required release-testing module $MODULE" ) + : plan( skip_all => "$MODULE not available for testing" ); + } +} + +all_pod_files_ok(qw'version.pl'); + +1; diff --git a/perl/t/version/sed.t b/perl/t/version/sed.t index e3bc2331..2b22dabf 100644 --- a/perl/t/version/sed.t +++ b/perl/t/version/sed.t @@ -14,9 +14,7 @@ our %test = load( use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; - +plan( tests => scalar keys %test ); my %map = ( diff --git a/perl/t/version/simple.t b/perl/t/version/simple.t index a77b0e94..ed0a0a9f 100644 --- a/perl/t/version/simple.t +++ b/perl/t/version/simple.t @@ -10,8 +10,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(2 * scalar keys %test); -die $@ if $@; +plan( tests => 2 * scalar keys %test ); for my $test ( sort keys %test ){ my $expected = $test{$test}; diff --git a/perl/t/version/yaml.t b/perl/t/version/yaml.t index eecfde94..9f72b92e 100644 --- a/perl/t/version/yaml.t +++ b/perl/t/version/yaml.t @@ -12,8 +12,7 @@ our %test = load( ); use Test::More; -eval "use Test::More 'tests' => ".(scalar keys %test); -die $@ if $@; +plan( tests => scalar keys %test ); for my $test ( sort keys %test ){ diff --git a/perl/version.pl b/perl/version.pl index 75afafef..3ff03f59 100755 --- a/perl/version.pl +++ b/perl/version.pl @@ -20,10 +20,15 @@ Where $format is one of: The NASM version number is assumed to consist of: -.[.][pl | rc]] +EmajorE.EminorE[.EsubminorE][ +plEpatchlevelE | +rcEnumberE +]]EtailE -... where is not necessarily numeric, but if it is of the form -- it is assumed to be a snapshot release. +... where EtailE is not necessarily numeric, but if it is of the form +-EdigitsE it is assumed to be a snapshot release. + +=head2 Output Formats =over 4 @@ -192,7 +197,7 @@ my %jump = ( usage => sub{ require Pod::Usage; - Pod::Usage::pod2usage(); + Pod::Usage::pod2usage("run pod2text $0 for more information"); } ); @@ -234,7 +239,7 @@ sub perl{ return Data::Dumper::Dumper(\%ret); } -=item yaml - returns the same thing as dump, but in YAML format +=item yaml - returns the same thing as perl, but in YAML format --- id: 33907556 @@ -261,7 +266,7 @@ sub yaml{ return Dump(\%ret); } -=item json - returns the same thing as dump, but in JSON format +=item json - returns the same thing as perl, but in JSON format { "rc" : 10, @@ -337,7 +342,7 @@ sub json{ # subroutine definitions -=item h: +=item h NASM_MAJOR_VER NASM_MINOR_VER @@ -374,7 +379,7 @@ END -=item mac: +=item mac __NASM_MAJOR__ __NASM_MINOR__ @@ -408,7 +413,7 @@ END -=item sed: +=item sed s/@@NASM_MAJOR@@/$major/g s/@@NASM_MINOR@@/$minor/g @@ -451,7 +456,7 @@ END -=item make: +=item make NASM_VER=$ver NASM_MAJOR_VER=$major @@ -473,7 +478,7 @@ END } -=item nsis: +=item nsis !define VERSION "$version" !define MAJOR_VER $major -- 2.11.4.GIT