ASPEER-MakeMaker-Markdown-Pod
view release on metacpan or search on metacpan
t/05-mm-integration.t view on Meta::CPAN
'target command explicitly reloads its dispatch module');
unlike($makefile, qr/^MM_PREFIX\s*=/m,
'private macro prefix configuration is not emitted');
like($makefile, qr/^\s*\@\$\(MARKPOD_PM_TARGET\) doc$/m,
'doc target passes its method explicitly');
like($makefile, qr/^LICENSE\s*=\s*perl$/m, 'license macro generated');
like(slurp('MYMETA.json'), qr/"license"\s*:\s*\[/,
'license metadata generated');
like($makefile, qr/^EXE_FILES\s*=\s*bin\/sample\.pl$/m,
'executable retains its declared filename');
ok(!-e 'bin/sample', 'extensionless executable is not created implicitly');
unlike($makefile, qr/lib\/Sample\.pm\.md\s+blib\//,
'Markdown sidecar excluded from install map');
like($makefile, qr/'LICENSE'\s+'\$\(INST_LIBDIR\)/,
'license file included in install map');
if (length($git_sha)) {
is(slurp('lib/Sample.pm.sha'), "$git_sha\n", 'Git-SHA provenance generated');
like($makefile, qr/lib\/Sample\.pm\.sha/, 'Git-SHA provenance included in install map');
utime(1000000000, 1000000000, 'lib/Sample.pm.sha') ||
die "unable to set Git-SHA fixture timestamp, $!";
}
else {
ok(!-e 'lib/Sample.pm.sha', 'Git-SHA generation skipped outside a checkout');
pass('Git-SHA install-map test skipped outside a checkout');
}
# Exercise the generated target rather than calling its implementation directly
#
my $make=$Config{'make'} || 'make';
is(system($make, 'doc'), 0, 'generated doc target succeeds');
like(slurp('lib/Sample.pm'), qr/^=head1 NAME$/m,
'generated target delegates Markdown conversion');
is(slurp('doc/guide.md'), "# Guide\n",
'generated target converts article XML absent from MANIFEST');
# Regenerate with optional integration declared inside Makefile.PL
#
my $embedded_import=<<'EMBEDDED_IMPORT';
eval {
require ASPEER::MakeMaker::Markdown::Pod;
ASPEER::MakeMaker::Markdown::Pod->import();
1;
};
EMBEDDED_IMPORT
my $makefile_pl=slurp('Makefile.PL');
$makefile_pl=~s/(use ExtUtils::MakeMaker;\n)/$1$embedded_import/ ||
die 'unable to add embedded import to Makefile.PL';
blurp('Makefile.PL', $makefile_pl);
is(system($^X, 'Makefile.PL'), 0,
'Makefile.PL succeeds with embedded optional import');
$makefile=slurp('Makefile');
like($makefile, qr/^PERLRUN\s*=.*-MASPEER::MakeMaker::Markdown::Pod/m,
'embedded import installs the full integration');
my @doc_target=($makefile=~/^doc :: readme$/mg);
is(scalar(@doc_target), 1, 'embedded import generates one doc target');
if (length($git_sha)) {
is((stat('lib/Sample.pm.sha'))[9], 1000000000,
'unchanged Git-SHA provenance is not rewritten');
}
else {
pass('Git-SHA rewrite test skipped outside a checkout');
}
# Command-line and embedded activation together remain idempotent
#
is(system($^X, '-MASPEER::MakeMaker::Markdown::Pod', 'Makefile.PL'), 0,
'combined command-line and embedded activation succeeds');
$makefile=slurp('Makefile');
@doc_target=($makefile=~/^doc :: readme$/mg);
is(scalar(@doc_target), 1, 'combined activation generates one doc target');
# Install executable Git provenance as data rather than as another executable
#
blurp('Makefile.PL', <<'MAKEFILE_PL');
use strict;
use warnings;
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Sample',
VERSION_FROM => 'bin/sample.pl',
EXE_FILES => ['bin/sample.pl'],
LICENSE => 'perl',
AUTHOR => 'Andrew Speer',
);
MAKEFILE_PL
is(system($^X, '-MASPEER::MakeMaker::Markdown::Pod', 'Makefile.PL'), 0,
'Makefile.PL succeeds with executable VERSION_FROM');
$makefile=slurp('Makefile');
like($makefile, qr/^EXE_FILES\s*=\s*bin\/sample\.pl$/m,
'Git-SHA sidecar is not treated as an executable');
if (length($git_sha)) {
is(slurp('bin/sample.pl.sha'), "$git_sha\n",
'executable Git-SHA provenance generated');
like($makefile,
qr/'bin\/sample\.pl\.sha'\s+'\$\(INST_SCRIPT\)\/sample\.pl\.sha'/,
'executable Git-SHA provenance mapped into INST_SCRIPT');
is(system($make, 'pure_all'), 0, 'executable Git-SHA provenance copied');
is(slurp('blib/script/sample.pl.sha'), "$git_sha\n",
'installed executable Git-SHA provenance retains its content');
}
else {
ok(!-e 'bin/sample.pl.sha',
'executable Git-SHA generation skipped outside a checkout');
pass('executable Git-SHA install-map test skipped outside a checkout');
pass('executable Git-SHA copy test skipped outside a checkout');
pass('installed executable Git-SHA content test skipped outside a checkout');
}
# A distribution without VERSION_FROM must not create a root .sha file
#
blurp('Makefile.PL', <<'MAKEFILE_PL');
use strict;
use warnings;
use ExtUtils::MakeMaker;
( run in 0.470 second using v1.01-cache-2.11-cpan-3b040b67cf0 )