| 1 |
#!perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Test::More tests => 20; |
| 5 |
my $class = 'Module::Depends::Intrusive'; |
| 6 |
require_ok("Module::Depends"); |
| 7 |
require_ok($class); |
| 8 |
|
| 9 |
my $our_requires = { |
| 10 |
'Class::Accessor::Chained' => 0, |
| 11 |
'File::chdir' => 0, |
| 12 |
'File::Spec' => 0, |
| 13 |
'YAML' => 0, |
| 14 |
}; |
| 15 |
|
| 16 |
# test against ourself |
| 17 |
my $mb = $class->new->dist_dir('t/old')->find_modules; |
| 18 |
is( $mb->error, '' ); |
| 19 |
isa_ok( $mb, $class ); |
| 20 |
|
| 21 |
is_deeply( $mb->requires, $our_requires, "got our own requires" ); |
| 22 |
|
| 23 |
is_deeply( |
| 24 |
$mb->build_requires, |
| 25 |
{ 'Test::More' => 0 }, |
| 26 |
"got our own build_requires" |
| 27 |
); |
| 28 |
|
| 29 |
my $other = $class->new->dist_dir("t/mmish")->find_modules; |
| 30 |
|
| 31 |
is_deeply( |
| 32 |
$other->requires, |
| 33 |
{ 'Not::A::Real::Module' => 42 }, |
| 34 |
"got other (makemaker) requires" |
| 35 |
); |
| 36 |
|
| 37 |
my $notthere = $class->new->dist_dir('t/no-such-dir')->find_modules; |
| 38 |
like( |
| 39 |
$notthere->error, |
| 40 |
qr{^couldn't chdir to t/no-such-dir: }, |
| 41 |
"fails on not existing dir" |
| 42 |
); |
| 43 |
|
| 44 |
$notthere->dist_dir('t/empty')->find_modules; |
| 45 |
like( |
| 46 |
$notthere->error, |
| 47 |
qr{^No {Build,Makefile}.PL found }, |
| 48 |
"fails on empty dir" |
| 49 |
); |
| 50 |
|
| 51 |
my $versioned = $class->new->dist_dir('t/build_version')->find_modules; |
| 52 |
is_deeply( |
| 53 |
$versioned->requires, |
| 54 |
{ 'Class::MethodMaker' => '1.02', |
| 55 |
'Term::ReadKey' => '2.14' |
| 56 |
}, |
| 57 |
"use Module::Build VERSION; no longer trips us up" |
| 58 |
); |
| 59 |
|
| 60 |
### gah, it seems File::chdir's localisation doesn't nest, otherwise we could use that here |
| 61 |
chdir 't/old'; |
| 62 |
my $shy = Module::Depends->new->dist_dir('.')->find_modules; |
| 63 |
chdir '../..'; |
| 64 |
is_deeply( $shy->requires, $our_requires, |
| 65 |
"got our own requires, non-intrusively" ); |
| 66 |
|
| 67 |
my $distant = Module::Depends->new->dist_dir('t/with-yaml')->find_modules; |
| 68 |
is_deeply( $distant->requires, $our_requires, |
| 69 |
"got our own requires, non-intrusively, from a distance" ); |
| 70 |
|
| 71 |
my $inline_mm = $class->new->dist_dir('t/inline-makemaker')->find_modules; |
| 72 |
is_deeply( |
| 73 |
$inline_mm->requires, |
| 74 |
{ 'Inline::C' => '0.44', |
| 75 |
'Time::Piece' => '1.08' |
| 76 |
}, |
| 77 |
"use Inline::MakeMaker; no longer trips us up" |
| 78 |
); |
| 79 |
|
| 80 |
my $module_install = $class->new->dist_dir('t/module-install')->find_modules; |
| 81 |
is( $module_install->error, '', "Module::Install no go boom" ); |
| 82 |
is_deeply( |
| 83 |
$module_install->build_requires, |
| 84 |
{ 'Test::More' => '0.54' }, |
| 85 |
"Module::Install build_requires" |
| 86 |
); |
| 87 |
|
| 88 |
is_deeply( |
| 89 |
$module_install->requires, |
| 90 |
{ 'perl' => '5.5.3' }, |
| 91 |
"Module::Install requires" |
| 92 |
); |
| 93 |
|
| 94 |
my $module_install_versioned = $class->new->dist_dir('t/module-install-versioned')->find_modules; |
| 95 |
is_deeply( |
| 96 |
$module_install_versioned->configure_requires, |
| 97 |
{ 'ExtUtils::Depends' => 0, |
| 98 |
'B::Hooks::OP::Check::EntersubForCV' => 0 }, |
| 99 |
"Module::Install explicit version, configure_requires" |
| 100 |
); |
| 101 |
|
| 102 |
|
| 103 |
my $template_extract |
| 104 |
= $class->new->dist_dir('t/template-extract')->find_modules; |
| 105 |
is_deeply( |
| 106 |
$template_extract->requires, |
| 107 |
{ 'perl' => '5.006', |
| 108 |
'Template' => 2 |
| 109 |
}, |
| 110 |
"Template::Extract Module::Install requires" |
| 111 |
); |
| 112 |
|
| 113 |
my $findbin = $class->new->dist_dir('t/uses-findbin')->find_modules; |
| 114 |
is_deeply( |
| 115 |
$findbin->requires, |
| 116 |
{ 'Not::A::Real::Module' => 42 }, |
| 117 |
"odd outcome use of FindBin" |
| 118 |
); |
| 119 |
|
| 120 |
my $mm_false = $class->new->dist_dir('t/makemaker-false')->find_modules; |
| 121 |
is( $mm_false->error, '', |
| 122 |
"Makefile.PL exiting false should not be considered an error", |
| 123 |
); |
| 124 |
|