| 1 | package TAPx::Harness::Compatible::Util; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | $VERSION = '0.50_07'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Exporter; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use vars qw( @ISA @EXPORT @EXPORT_OK ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | @ISA = qw( Exporter ); | |||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | @EXPORT = (); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | @EXPORT_OK = qw( all_in shuffle blibdirs ); | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | TAPx::Harness::Compatible::Util - Utility functions for TAPx::Harness::Compatible::* | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | Utility functions for TAPx::Harness::Compatible::* | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 PUBLIC FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | The following are all available to be imported to your module. No symbols | ||||||||||||||||||||||||||||||||||||||||||
| 26 | are exported by default. | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head2 all_in( {parm => value, parm => value} ) | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | Finds all the F<*.t> in a directory. Knows to skip F<.svn> and F<CVS> | ||||||||||||||||||||||||||||||||||||||||||
| 31 | directories. | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | Valid parms are: | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =item start | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Starting point for the search. Defaults to ".". | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =item recurse | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | Flag to say whether it should recurse. Default to true. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub all_in { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
all_in: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $parms = shift; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my %parms = ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | start => ".", | ||||||||||||||||||||||||||||||||||||||||||
| 53 | recurse => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | %$parms, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my @hits = (); | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $start = $parms{start}; | |||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | local *DH; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if ( opendir( DH, $start ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my @files = sort readdir DH; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | closedir DH; | |||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | for my $file (@files) { | |||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | next if $file eq File::Spec->updir || $file eq File::Spec->curdir; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$file eq "File::Spec"->updir or $file eq "File::Spec"->curdir
MC/DC0%0/2
$file eq "File::Spec"->updir or $file eq "File::Spec"->curdir
$file eq "File::Spec"->updir
$file eq "File::Spec"->curdir
Truth table0%0/3
A or B
A= $file eq "File::Spec"->updirB= $file eq "File::Spec"->curdir
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | next if $file eq ".svn"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | next if $file eq "CVS"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $currfile = File::Spec->catfile( $start, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( -d $currfile ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | push( @hits, all_in( { %parms, start => $currfile } ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if $parms{recurse}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | push( @hits, $currfile ) if $currfile =~ /\.t$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | warn "$start: $!\n"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | return @hits; | |||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =head1 shuffle( @list ) | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | Returns a shuffled copy of I<@list>. | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub shuffle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shuffle: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | # Fisher-Yates shuffle | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my $i = @_; | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | while ($i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $j = rand $i--; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | @_[ $i, $j ] = @_[ $j, $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | =head2 blibdir() | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Finds all the blib directories. Stolen directly from blib.pm | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub blibdirs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blibdirs: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $dir = File::Spec->curdir; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if ( $^O eq 'VMS' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ( $dir = VMS::Filespec::unixify($dir) ) =~ s-/\z--; | |||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | my $archdir = "arch"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if ( $^O eq "MacOS" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | # Double up the MP::A so that it's not used only once. | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $archdir = $MacPerl::Architecture = $MacPerl::Architecture; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $i = 5; | |||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | while ( $i-- ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $blib = File::Spec->catdir( $dir, "blib" ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $blib_lib = File::Spec->catdir( $blib, "lib" ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $blib_arch = File::Spec->catdir( $blib, $archdir ); | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | if ( -d $blib && -d $blib_arch && -d $blib_lib ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
-d $blib and -d $blib_arch and -d $blib_lib
-d $blib and -d $blib_arch
MC/DC0%0/3
-d $blib and -d $blib_arch and -d $blib_lib
-d $blib
-d $blib_arch
-d $blib_lib
Truth table0%0/4
A and B and C
A= -d $blibB= -d $blib_archC= -d $blib_lib
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | return ( $blib_arch, $blib_lib ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $dir = File::Spec->catdir( $dir, File::Spec->updir ); | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | warn "$0: Cannot find blib\n"; | |||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | =head1 TO DOCUMENT | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | =item blibdirs | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | TODO: Document blibdirs | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | =item shuffle | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | TODO: Document shuffle | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | =back | ||||||||||||||||||||||||||||||||||||||||||