$ENV
{FAKE_RELEASE} = 1;
my
$tempdir
= no_git_tempdir();
my
@network_plugins
= Dist::Zilla::PluginBundle::Author::ETHER->_network_plugins;
my
%network_plugins
;
@network_plugins
{
map
Dist::Zilla::Util->expand_config_package_name(
$_
),
@network_plugins
} = () x
@network_plugins
;
my
@tests
= (
{
test_name
=>
'no removals'
,
remove_plugins
=> [],
unwanted_plugins
=> \
@network_plugins
,
},
{
test_name
=>
'remove things referenced by short form, full name, moniker'
,
remove_plugins
=> [
'=Dist::Zilla::Plugin::Keywords'
,
'generate CONTRIBUTING'
],
unwanted_plugins
=> [
@network_plugins
,
qw(Keywords GenerateFile::FromShareDir)
,
],
},
);
subtest
$_
->{test_name} =>
sub
{
my
$remove
=
$_
->{remove_plugins};
my
$expected_removals
=
$_
->{unwanted_plugins};
my
$tzil
;
my
@warnings
= warnings {
$tzil
= Builder->from_config(
{
dist_root
=>
'does-not-exist'
},
{
tempdir_root
=>
$tempdir
->stringify,
add_files
=> {
path(
qw(source dist.ini)
) => simple_ini(
[
'@Author::ETHER'
=> {
server
=>
'none'
,
'Test::MinimumVersion.max_target_perl'
=>
'5.008'
,
'RewriteVersion::Transitional.skip_version_provider'
=> 1,
airplane
=> 1,
@$remove
? (
'-remove'
=>
$remove
) : (),
} ],
),
path(
qw(source lib DZT Sample.pm)
) =>
''
,
path(
qw(source Changes)
) =>
''
,
},
},
);
};
my
@plugin_classes
=
map
find_meta(
$_
)->name, @{
$tzil
->plugins};
cmp_deeply(
[
grep
exists
$network_plugins
{
$_
},
@plugin_classes
],
[],
'no network-using plugins were actually added'
,
);
ok(
do
{
my
$add
=
$_
; any {
$_
eq
'Dist::Zilla::Plugin::'
.
$add
}
@plugin_classes
},
$_
.
' found in plugin list'
,
)
foreach
qw(FakeRelease BlockRelease)
;
ok(
do
{
my
$rem
=
$_
; none {
$_
eq
'Dist::Zilla::Plugin::'
.
$rem
}
@plugin_classes
},
$_
.
' not found in plugin list'
,
)
foreach
@$expected_removals
;
my
@expected_log_messages
= (
'building in airplane mode - plugins requiring the network are skipped, and releases are not permitted'
,
'FAKE_RELEASE set - not uploading to CPAN'
,
);
my
$ok
= cmp_deeply(
[
map
colorstrip(
$_
),
@warnings
],
superbagof(
map
re(
qr/^\[\@Author::ETHER\] $_/
),
@expected_log_messages
),
'we warn when in airplane mode, and performing a fake release'
,
) or diag explain
@warnings
;
push
@expected_log_messages
,
'.git is missing and META.json is present -- this looks like a CPAN download rather than a git repository. You should probably run perl Build.PL; ./Build instead of using dzil commands!'
;
@warnings
=
grep
{
my
$warning
=
$_
; not
grep
$warning
=~ /
$_
/,
@expected_log_messages
}
@warnings
;
warn
@warnings
if
@warnings
and
$ok
;
}
foreach
@tests
;
had_no_warnings
if
$ENV
{AUTHOR_TESTING};
done_testing;