Skip to content

Commit acc70a0

Browse files
SmylersFather Chrysostomos
authored and
Father Chrysostomos
committed
Test that README and perl -v copyright years match
1 parent 9ff0b39 commit acc70a0

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5371,6 +5371,7 @@ t/porting/bincompat.t Check that {non_,}bincompat_options are ordered
53715371
t/porting/checkcase.t Check whether we are case-insensitive-fs-friendly
53725372
t/porting/checkcfgvar.t Check that all config.sh-like files are good
53735373
t/porting/cmp_version.t Test whether all changed module files have their VERSION bumped
5374+
t/porting/copyright.t Check that copyright years match
53745375
t/porting/customized.dat Data file for porting/customized.t
53755376
t/porting/customized.t Check all CUSTOMIZED files are as they should be
53765377
t/porting/diag.t Test completeness of perldiag.pod

t/porting/copyright.t

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!perl
2+
3+
=head1 NAME
4+
5+
copyright.t
6+
7+
=head1 DESCRIPTION
8+
9+
Tests that the latest copyright years in the top-level README file and the
10+
C<perl -v> output match each other.
11+
12+
If the test fails, update at least one of README and perl.c so that they match
13+
reality.
14+
15+
=cut
16+
17+
18+
use TestInit;
19+
use strict;
20+
BEGIN { require 'test.pl' }
21+
22+
23+
my $readme_year = readme_year();
24+
my $v_year = v_year();
25+
is $readme_year, $v_year, 'README and perl -v copyright dates match';
26+
27+
done_testing;
28+
29+
30+
sub readme_year
31+
# returns the latest copyright year from the top-level README file
32+
{
33+
34+
open my $readme, '<', '../README' or die "Opening README failed: $!";
35+
36+
# The copyright message is the first paragraph:
37+
local $/ = '';
38+
my $copyright_msg = <$readme>;
39+
40+
my ($year) = $copyright_msg =~ /.*\b(\d{4,})/s
41+
or die "Year not found in README copyright message '$copyright_msg'";
42+
43+
$year;
44+
}
45+
46+
47+
sub v_year
48+
# returns the latest copyright year shown in perl -v
49+
{
50+
51+
my $output = runperl switches => ['-v'];
52+
my ($year) = $output =~ /copyright 1987.*\b(\d{4,})/i
53+
or die "Copyright statement not found in perl -v output '$output'";
54+
55+
$year;
56+
}

0 commit comments

Comments
 (0)