ASPEER-MakeMaker
view release on metacpan or search on metacpan
t/ASPEER-MakeMaker.t view on Meta::CPAN
'all',
'.pm',
'lib/ASPEER/MakeMaker.pm',
);
sub target_args {
my ($to_inst_pm, @argv)=@_;
my @args=@makemaker_args;
$args[9]=$to_inst_pm;
return (@args, @argv);
}
my $postamble=do {
open(my $fh, '<', $TEMPLATE_POSTAMBLE_FN)
or die "unable to open $TEMPLATE_POSTAMBLE_FN: $!";
local $/;
<$fh>;
};
unlike(
$postamble,
qr/^ASPEER_MAKEMAKER_PM_TARGET=/m,
'postamble leaves platform command generation to MakeMaker'
);
like(
$postamble,
qr/\$\(ASPEER_MAKEMAKER_PM_TARGET\) util_sync \$\(UPDATE_SOURCE_UTIL_FN\)/,
'postamble passes util_sync method and utility source explicitly'
);
unlike(
$postamble,
qr/(?:gherkin|foobar|serfin)/,
'postamble contains no demonstration targets or missing methods'
);
is(
scalar split(/,/, $ASPEER_MAKEMAKER_PM_ARGV),
scalar @makemaker_args,
'test MakeMaker argument list matches postamble macro arity'
);
ok(
ASPEER::MakeMaker->util_sync(target_args($dest_fn, $UPDATE_SOURCE_UTIL_FN)),
'util_sync copies utility file to trial destination'
);
ok(-e $dest_fn, 'trial destination exists');
like(
ASPEER::MakeMaker::MM::Util::slurp($dest_fn),
qr/\$VERSION='0\.777'/,
'util_sync applies the version parsed from VERSION_FROM'
);
my $source_size=-s $UPDATE_SOURCE_UTIL_FN;
my $dest_size=-s $dest_fn;
is($dest_size, $source_size, 'trial destination has source size');
my $source_mtime=(stat($UPDATE_SOURCE_UTIL_FN))[9];
utime($source_mtime + 100, $source_mtime + 100, $dest_fn)
or die "utime failed for $dest_fn: $!";
ok(
ASPEER::MakeMaker->util_sync(target_args($dest_fn, $UPDATE_SOURCE_UTIL_FN)),
'util_sync overwrites existing destination'
);
is((stat($dest_fn))[9], $source_mtime, 'util_sync preserves the source timestamp');
like(
do {
local $@;
eval { ASPEER::MakeMaker->util_sync(target_args($UPDATE_SOURCE_UTIL_FN, $UPDATE_SOURCE_UTIL_FN)) };
$@;
},
qr/source and destination are the same/,
'util_sync refuses same source and destination'
);
( run in 1.022 second using v1.01-cache-2.11-cpan-3b040b67cf0 )