File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -623,6 +623,17 @@ sub is_pod_file {
623
623
shift -> name =~ / \. pod$ /i ;
624
624
}
625
625
626
+ =head2 in_test_directory
627
+
628
+ Returns true if the file is below a t directory.
629
+
630
+ =cut
631
+
632
+ sub in_test_directory {
633
+ my $self = shift ;
634
+ return ( $self -> path =~ / (^|\/ )t($| \/ )/ ? 1 : 0 );
635
+ }
636
+
626
637
=head2 add_module
627
638
628
639
Requires at least one parameter which can be either a HashRef or
Original file line number Diff line number Diff line change @@ -12,6 +12,24 @@ my %stub = (
12
12
name => ' module.pm' ,
13
13
);
14
14
15
+ {
16
+ my %paths = (
17
+ ' t/whomp' => 1,
18
+ ' foo/t/bar' => 1,
19
+ ' cuppa/t' => 1,
20
+ ' foo/bart/shorts' => 0,
21
+ ' tit/mouse' => 0,
22
+ ' say/wat' => 0,
23
+ );
24
+
25
+ foreach my $path ( keys %paths ) {
26
+ my $file = MetaCPAN::Document::File-> new( %stub , path => $path );
27
+ my $bool = $paths {$path } ? ' is' : ' is not' ;
28
+ is( $file -> in_test_directory(),
29
+ $paths {$path }, " $path $bool in a test directory" );
30
+ }
31
+ }
32
+
15
33
{
16
34
my $content = <<'END' ;
17
35
package Foo;
You can’t perform that action at this time.
0 commit comments