File Coverage

t/PerlySense-Project-find.t
Criterion Covered Total %
statement 83 83 100.0
branch 1 2 50.0
condition n/a
subroutine 13 13 100.0
pod n/a
total 97 98 98.9


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2 1     1   137938 use strict;
  1         3  
  1         64  
3              
4 1     1   518 use Test::More tests => 21;
  1         24127  
  1         64  
5 1     1   810 use Test::Exception;
  1         2883  
  1         4  
6              
7 1     1   970 use Data::Dumper;
  1         13678  
  1         83  
8              
9 1     1   389 use lib "../lib";
  1         512  
  1         4  
10              
11 1     1   89141 use_ok("Devel::PerlySense::Project");
  1         466  
  1         2  
  1         2  
  1         8  
12 1     1   272 use_ok("Devel::PerlySense::Project::Unknown");
  1         73  
  1         2  
  1         2  
  1         7  
13 1     1   193 use_ok("Devel::PerlySense");
  1         55  
  1         2  
  1         1  
  1         6  
14              
15              
16 1 50   1   216 BEGIN { -d "t" and chdir("t"); }
17              
18              
19              
20 1         194 ok(
21             my $oProjectUnknown = Devel::PerlySense::Project::Unknown->new(),
22             "Created Unknown project ok",
23             );
24 1         195 isa_ok($oProjectUnknown, "Devel::PerlySense::Project");
25 1         236 isa_ok($oProjectUnknown, "Devel::PerlySense::Project::Unknown");
26              
27              
28 1         223 ok(
29             my $oPerlySense = Devel::PerlySense->new(),
30             "New PerlySense object ok",
31             );
32              
33              
34              
35 1         189 is(
36             Devel::PerlySense::Project->newFromLocation(
37             oPerlySense => $oPerlySense,
38             dir => "/",
39             ),
40             undef,
41             "Found nothing, looking at the / dir",
42             );
43              
44              
45              
46              
47 1         296 note("Look for dirs that indicate a project");
48             {
49              
50             #This is to avoid identifying the .PerlySenseProject directory
51             #_of_the_development_project_ to interfere with the test which
52             #expects a free way all the way up to the root without any
53             #projects.
54 1     1   43 no warnings;
  1         3  
  1         1  
  1         264  
55             local *Devel::PerlySense::Project::newFindExplicit = sub {
56 2     2   14 undef;
57 1         6 };
58              
59 1         3 my $dirBase = "data/project/with-dir";
60 1         2 my $dirProject = "$dirBase/source";
61              
62 1         1 my $rexDirProject = $dirProject;
63 1         5 $rexDirProject =~ s|\W|.|g;
64              
65              
66 1         3 my $dirTest = "$dirProject/lib/Game";
67 1         2 my $fileTest = "$dirTest/Lawn.pm";
68              
69 1         5 ok(
70             my $oProjectDir = Devel::PerlySense::Project->newFromLocation(
71             dir => $dirTest,
72             oPerlySense => $oPerlySense,
73             ),
74             "Found Project using dir",
75             );
76 1         279 like($oProjectDir->dirProject, qr/$rexDirProject$/, " Correct Project dir");
77 1         210 like(
78             $oProjectDir->dirProjectImplicitDir,
79             qr/$rexDirProject$/,
80             " Correct Project dir property",
81             );
82              
83 1         185 ok(
84             my $oProjectFile = Devel::PerlySense::Project->newFromLocation(
85             file => $fileTest,
86             oPerlySense => $oPerlySense,
87             ),
88             "Found Project using file",
89             );
90 1         373 like($oProjectFile->dirProject, qr/$rexDirProject$/, " Correct Project dir");
91 1         603 is(
92             $oProjectFile->dirProjectImplicitDir,
93             "",
94             " Correct Project dir property",
95             );
96 1         426 like(
97             $oProjectFile->dirProjectImplicitUse,
98             qr/$rexDirProject$/,
99             " Correct Project dir property",
100             );
101              
102             }
103              
104              
105              
106              
107 1         424 note("Look for the modules itself that indicate a project");
108             {
109             #See above.
110 1     1   215 no warnings;
  1         3  
  1         1  
  1         1539  
111             local *Devel::PerlySense::Project::newFindExplicit = sub {
112 1     1   10 undef;
113 1         6 };
114              
115 1         2 my $dirBase = "data/project/with-use";
116 1         3 my $dirProject = "$dirBase/source/lib";
117              
118 1         1 my $rexDirProject = $dirProject;
119 1         5 $rexDirProject =~ s|\W|.|g;
120              
121 1         2 my $dirTest = "$dirProject/modules/Game";
122 1         4 my $fileTest = "$dirTest/Lawn.pm";
123              
124 1         6 ok(
125             my $oProjectFile = Devel::PerlySense::Project->newFromLocation(
126             file => $fileTest,
127             oPerlySense => $oPerlySense,
128             ),
129             "Found Project using file",
130             );
131 1         807 like($oProjectFile->dirProject, qr/$rexDirProject$/, " Correct Project dir");
132 1         473 like(
133             $oProjectFile->dirProjectImplicitUse,
134             qr/$rexDirProject$/,
135             " Correct Project dir property",
136             );
137              
138             }
139              
140              
141              
142              
143              
144 1         401 note("Look for a .PerlySenseProject indicate a project");
145             {
146              
147 1         206 my $dirBase = "data/project/with-perlysenseproject";
  1         2  
148 1         2 my $dirProject = "$dirBase/source";
149              
150 1         2 my $rexDirProject = $dirProject;
151 1         5 $rexDirProject =~ s|\W|.|g;
152              
153 1         3 my $dirTest = "$dirProject/bogus/lib/Game";
154 1         2 my $fileTest = "$dirTest/Lawn.pm";
155              
156 1         5 ok(
157             my $oProjectFile = Devel::PerlySense::Project->newFromLocation(
158             file => $fileTest,
159             oPerlySense => $oPerlySense,
160             ),
161             "Found Project using .PerlySenseProject",
162             );
163 1         428 like($oProjectFile->dirProject, qr/$rexDirProject$/, " Correct Project dir");
164 1         211 like(
165             $oProjectFile->dirProjectExplicitDir,
166             qr/$rexDirProject$/,
167             " Correct Project dir property",
168             );
169              
170             }
171              
172              
173              
174              
175              
176             __END__