1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
#perl -T
# This test suite ensures that Module::Starter::BuilderSet behaves
use strict;
use warnings;
use Test::More tests => 17;
eval { require Module::Starter::BuilderSet };
ok(!$@, 'require Module::Starter::BuilderSet');
my $bset = Module::Starter::BuilderSet->new;
isa_ok($bset, 'Module::Starter::BuilderSet');
can_ok($bset, qw( default_builder
supported_builders
file_for_builder
instructions_for_builder
deps_for_builder
method_for_builder
check_compatibility
)
);
ok( ( grep { $bset->default_builder() eq $_ } $bset->supported_builders() ),
'default builder is in the list of supported builders'
);
ok( ( !grep { !$bset->file_for_builder($_) } $bset->supported_builders() ),
'all supported builders claim to generate a file'
);
ok( (!grep {!$bset->instructions_for_builder($_)} $bset->supported_builders()),
'all supported builders provide build instructions'
);
foreach my $builder ( $bset->supported_builders() ){
foreach my $dep ($bset->deps_for_builder($builder)){
ok( exists $dep->{command} && $dep->{command} ne '',
"dependency command for '$builder' is set"
);
ok(exists $dep->{aliases} &&
ref $dep->{aliases} eq 'ARRAY' &&
int( @{ $dep->{aliases} } ) > 0,
"aliases look correct for builder '$builder', dep '$dep->{command}'"
);
}
}
use Module::Starter::Simple;
my $simple = bless {}, 'Module::Starter::Simple';
can_ok( $simple,
map { $bset->method_for_builder($_) } $bset->supported_builders()
);
my @incompat =
(
'ExtUtils::MakeMaker',
'Module::Install',
);
my @compat =
( 'Module::Build',
'Module::Install',
);
my @nonexistent =
( 'CJAC::Boing',
'CJAC::Flop',
);
ok( int( $bset->check_compatibility() ) == 1 &&
( $bset->check_compatibility() )[0] eq $bset->default_builder(),
'check_compatibility() with no args returns default builder'
);
my @return;
# Capture warnings printed to STDERR
{
local *STDERR;
open STDERR, q{>}, File::Spec->devnull();
@return = $bset->check_compatibility(@nonexistent);
}
ok( int( @return ) == 1 &&
$return[0] eq $bset->default_builder(),
'check_compatibility() with unsupported builder returns default builder'
);
my @return2;
# Capture warnings printed to STDERR
{
local *STDERR;
open STDERR, q{>}, File::Spec->devnull();
@return = $bset->check_compatibility(@incompat);
@return2 = $bset->check_compatibility(reverse @incompat);
}
ok( int( @return ) != int( @incompat ),
'check_compatibility() strips incompatible builder'
);
ok( $return[0] eq $incompat[0] && $return2[0] eq $incompat[-1],
'check_compatibility() gives precidence to the first module passed'
);
is_deeply( [($bset->check_compatibility(@compat))],
[@compat],
"check_compatibility() returns all compatible builders"
);
# Capture warnings printed to STDERR
{
local *STDERR;
open STDERR, q{>}, File::Spec->devnull();
@return = $bset->check_compatibility(@compat, @incompat, @nonexistent);
}
is_deeply( \@return, \@compat,
"check_compatibility() returns only compatible builders ".
"when given mixed set of compatible, incompatible and nonsense"
);
|