From: Robert 'phaylon' Sedlacek Date: Tue, 8 May 2012 19:25:42 +0000 (+0000) Subject: LibDirs::Perl probe tests X-Git-Tag: v0.001_001~112 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b112c9f33a6697b44b6faca2983cfde0ed05198f;p=scpubgit%2FSystem-Introspector.git LibDirs::Perl probe tests --- diff --git a/t/data/libdir/perl/lib/perl5/Foo.pm b/t/data/libdir/perl/lib/perl5/Foo.pm new file mode 100644 index 0000000..d781edd --- /dev/null +++ b/t/data/libdir/perl/lib/perl5/Foo.pm @@ -0,0 +1,5 @@ +package Foo; + +our $VERSION = 0.001; + +1; diff --git a/t/libdirs-perl.t b/t/libdirs-perl.t new file mode 100644 index 0000000..799a7da --- /dev/null +++ b/t/libdirs-perl.t @@ -0,0 +1,35 @@ +use strictures 1; +use Test::More; +use FindBin; + +use System::Introspector::LibDirs::Perl; + +my $dir = "$FindBin::Bin/data/libdir/perl"; + +no warnings 'redefine'; +*System::Introspector::LibDirs::Perl::_open_locate_libdirs_pipe = sub { + my $output = "$dir/lib/perl5\n"; + open my $fh, '<', \$output; + return $fh; +}; + +my $probe = System::Introspector::LibDirs::Perl->new( + root => $dir, +); +my $data = $probe->gather; + +my $sha = delete $data->{"$dir/lib/perl5"}{Foo}[0]{sha256_hex}; +ok $sha, 'contains SHA fingerprint'; + +my $size = delete $data->{"$dir/lib/perl5"}{Foo}[0]{size}; +ok $size, 'contains file size'; + +is_deeply $data, { + "$dir/lib/perl5" => { + Foo => [ + { file => "$dir/lib/perl5/Foo.pm", version => 0.001 }, + ], + }, +}, 'package found'; + +done_testing;