#!perl
BEGIN {
require
'./test.pl'
}
if
(
$Config
{usecrosscompile} ) {
skip_all(
"Not all files are available during cross-compilation"
);
}
my
(
$opt
) =
@ARGV
;
my
$readme_year
= readme_year();
my
$v_year
= v_year();
if
(
$opt
eq
'--now'
)
{
my
$current_year
= (
gmtime
)[5] + 1900;
is
$v_year
,
$current_year
,
'perl -v copyright includes current year'
;
is
$readme_year
,
$current_year
,
'README copyright includes current year'
;
}
else
{
is
$readme_year
,
$v_year
,
'README and perl -v copyright dates match'
;
}
done_testing;
sub
readme_year
{
open
my
$readme
,
'<'
,
'../README'
or
die
"Opening README failed: $!"
;
local
$/ =
''
;
my
$copyright_msg
= <
$readme
>;
my
(
$year
) =
$copyright_msg
=~ /.*\b(\d{4,})/s
or
die
"Year not found in README copyright message '$copyright_msg'"
;
$year
;
}
sub
v_year
{
my
$output
= runperl
switches
=> [
'-v'
];
my
(
$year
) =
$output
=~ /copyright 1987.*\b(\d{4,})/i
or
die
"Copyright statement not found in perl -v output '$output'"
;
$year
;
}