diff options
author | Smylers <Smylers@stripey.com> | 2013-09-06 11:07:27 +0100 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-09-10 08:43:13 -0700 |
commit | acc70a0776c85acb28f75858cf80c469926498a9 (patch) | |
tree | b888d1745f0aab2f1e01a7336fa839f7a4c0875e /t | |
parent | 9ff0b3932d7485081c0ceb0cd34a884424765426 (diff) | |
download | perl-acc70a0776c85acb28f75858cf80c469926498a9.tar.gz |
Test that README and perl -v copyright years match
Diffstat (limited to 't')
-rw-r--r-- | t/porting/copyright.t | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/t/porting/copyright.t b/t/porting/copyright.t new file mode 100644 index 0000000000..e1b7faa229 --- /dev/null +++ b/t/porting/copyright.t @@ -0,0 +1,56 @@ +#!perl + +=head1 NAME + +copyright.t + +=head1 DESCRIPTION + +Tests that the latest copyright years in the top-level README file and the +C<perl -v> output match each other. + +If the test fails, update at least one of README and perl.c so that they match +reality. + +=cut + + +use TestInit; +use strict; +BEGIN { require 'test.pl' } + + +my $readme_year = readme_year(); +my $v_year = v_year(); +is $readme_year, $v_year, 'README and perl -v copyright dates match'; + +done_testing; + + +sub readme_year +# returns the latest copyright year from the top-level README file +{ + + open my $readme, '<', '../README' or die "Opening README failed: $!"; + + # The copyright message is the first paragraph: + 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 +# returns the latest copyright year shown in perl -v +{ + + 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; +} |