]>
git.saurik.com Git - apple/security.git/blob - SecurityTests/regressions/inc/Test/Harness/Util.pm
1 package Test
::Harness
::Util
;
9 use vars
qw( @ISA @EXPORT @EXPORT_OK );
11 @ISA = qw( Exporter );
13 @EXPORT_OK = qw( all_in shuffle blibdirs );
17 Test::Harness::Util - Utility functions for Test::Harness::*
21 Utility functions for Test::Harness::*
23 =head1 PUBLIC FUNCTIONS
25 The following are all available to be imported to your module. No symbols
26 are exported by default.
28 =head2 all_in( {parm => value, parm => value} )
30 Finds all the F<*.t> in a directory. Knows to skip F<.svn> and F<CVS>
39 Starting point for the search. Defaults to ".".
43 Flag to say whether it should recurse. Default to true.
58 my $start = $parms{start
};
61 if ( opendir( DH
, $start ) ) {
62 my @files = sort readdir DH
;
64 for my $file ( @files ) {
65 next if $file eq File
::Spec-
>updir || $file eq File
::Spec-
>curdir;
66 next if $file eq ".svn";
67 next if $file eq "CVS";
69 my $currfile = File
::Spec-
>catfile( $start, $file );
71 push( @hits, all_in
( { %parms, start
=> $currfile } ) ) if $parms{recurse
};
74 push( @hits, $currfile ) if $currfile =~ /\.t$/;
85 =head1 shuffle( @list )
87 Returns a shuffled copy of I<@list>.
92 # Fisher-Yates shuffle
96 @_[$i, $j] = @_[$j, $i];
103 Finds all the blib directories. Stolen directly from blib.pm
108 my $dir = File
::Spec-
>curdir;
110 ($dir = VMS
::Filespec
::unixify
($dir)) =~ s-
/\z--
;
112 my $archdir = "arch";
113 if ( $^O eq "MacOS" ) {
114 # Double up the MP::A so that it's not used only once.
115 $archdir = $MacPerl::Architecture
= $MacPerl::Architecture
;
120 my $blib = File
::Spec-
>catdir( $dir, "blib" );
121 my $blib_lib = File
::Spec-
>catdir( $blib, "lib" );
122 my $blib_arch = File
::Spec-
>catdir( $blib, $archdir );
124 if ( -d
$blib && -d
$blib_arch && -d
$blib_lib ) {
125 return ($blib_arch,$blib_lib);
127 $dir = File
::Spec-
>catdir($dir, File
::Spec-
>updir);
129 warn "$0: Cannot find blib\n";