File Coverage

t/PerlySense-Project-file-in-project.t
Criterion Covered Total %
statement 60 60 100.0
branch 2 4 50.0
condition n/a
subroutine 11 11 100.0
pod n/a
total 73 75 97.3


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   244998 use strict;
  1         2  
  1         64  
3              
4 1     1   521 use Test::More tests => 14;
  1         25178  
  1         8  
5 1     1   723 use Test::Exception;
  1         3324  
  1         4  
6              
7 1     1   230 use Cwd;
  1         1  
  1         96  
8 1     1   419 use Data::Dumper;
  1         6033  
  1         42  
9 1     1   385 use Path::Class;
  1         32980  
  1         46  
10              
11 1     1   332 use lib ("lib", "../lib");
  1         516  
  1         4  
12              
13 1     1   338 use Devel::PerlySense::Util::Log;
  1         1  
  1         58  
14              
15 1     1   87894 use_ok("Devel::PerlySense::Project");
  1         380  
  1         3  
  1         1  
  1         8  
16 1     1   276 use_ok("Devel::PerlySense");
  1         75  
  1         1  
  1         1  
  1         5  
17              
18              
19 1 50   1   1655 BEGIN { -d "t" and chdir("t"); }
20              
21              
22              
23 1         193 ok(
24             my $oPerlySense = Devel::PerlySense->new(),
25             "New PerlySense object ok",
26             );
27              
28              
29              
30 1         194 my $dirBase = "data/project/with-perlysenseproject";
31 1         3 my $dirProject = "$dirBase/source";
32              
33 1         3 my $dirTest = "$dirProject/bogus/lib/Game";
34 1         2 my $fileTest = "$dirTest/Lawn.pm";
35              
36 1         3 my @aDirTest = (
37             "glib/perl5lib",
38             "deps/perl5lib",
39             "../../with-dir/source/lib",
40             );
41              
42              
43 1         4 ok($oPerlySense->setFindProject(file => $fileTest), "Found Project");
44 1         323 my $oProject = $oPerlySense->oProject;
45 1         7 like($oProject->dirProject, qr/with-perlysenseproject.source$/, "Got good project root dir");
46 1         205 is_deeply(
47             $oPerlySense->rhConfig->{project}->{inc_dir},
48             [ @aDirTest ],
49             );
50              
51              
52 1         453 my $file;
53              
54 1         3 $file = $fileTest;
55 1         5 ok(!$oProject->isFileInProject(file => "dsfjdslk"), "Completely missing file is not in project");
56              
57 1         273 ok( $oProject->isFileInProject(file => $fileTest), "Same file is in project");
58 1         200 ok( $oProject->isFileInProject(file => "$fileTest.missing"), "Missing file that could be in project is. It does not have to exist");
59              
60 1         260 ok(!$oProject->isFileInProject(file => "data/inc-lib/Game/Object/Worm.pm"), "Existing file outside of project isn't in project");
61              
62              
63 1         268 note("Test inc_dir");
64             #This dir is in the inc_dir according to the loaded yaml config
65 1 50       46 ok(
66             $oProject->isFileInProject(file => "data/project/with-dir/source/lib/Game/Lawn.pm"),
67             "Missing file that could be in project is. It does not have to exist",
68             ) or warn( Devel::PerlySense::Util::Log->_textTailDebug() . "\n\nTEST FAILED, THIS ABOVE TEXT IS THE RECENT DEBUG LOG FOR DIAGNOSTICS PURPOSES.\nSORRY ABOUT SPAMMING LIKE THIS, BUT I NEED THE OUTPUT TO FIGURE OUT WHAT'S WRONG\n" );
69              
70              
71              
72              
73 1         290 note("inc_dir");
74 1         6930 my $dirBaseAbs = dir(cwd(), $dirProject);
75 1         2640 my %hIncDirAbsolute = map { $_ => 1 } $oProject->aDirIncAbsolute;
  5         29  
76              
77 1         10 for my $dir (@aDirTest) {
78 3         3869 my $dirAbs = dir($dirBaseAbs, $dir );
79 3         235 ok( $hIncDirAbsolute{$dirAbs}, "Found absolute dir for ($dir) ($dirAbs)");
80             }
81              
82              
83              
84             __END__