This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test that README and perl -v copyright years match
authorSmylers <Smylers@stripey.com>
Fri, 6 Sep 2013 10:07:27 +0000 (11:07 +0100)
committerFather Chrysostomos <sprout@cpan.org>
Tue, 10 Sep 2013 15:43:13 +0000 (08:43 -0700)
MANIFEST
t/porting/copyright.t [new file with mode: 0644]

index 4679c95..6541f67 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -5371,6 +5371,7 @@ t/porting/bincompat.t             Check that {non_,}bincompat_options are ordered
 t/porting/checkcase.t          Check whether we are case-insensitive-fs-friendly
 t/porting/checkcfgvar.t                Check that all config.sh-like files are good
 t/porting/cmp_version.t                Test whether all changed module files have their VERSION bumped
+t/porting/copyright.t          Check that copyright years match
 t/porting/customized.dat               Data file for porting/customized.t
 t/porting/customized.t         Check all CUSTOMIZED files are as they should be
 t/porting/diag.t               Test completeness of perldiag.pod
diff --git a/t/porting/copyright.t b/t/porting/copyright.t
new file mode 100644 (file)
index 0000000..e1b7faa
--- /dev/null
@@ -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;
+}