[svn:parrot] r37387 - trunk/t/codingstd

coke at svn.parrot.org coke at svn.parrot.org
Fri Mar 13 19:34:18 UTC 2009


Author: coke
Date: Fri Mar 13 19:34:17 2009
New Revision: 37387
URL: https://trac.parrot.org/parrot/changeset/37387

Log:
[t] make copyright test fail on duplicate copyright notices.
(Catches those with multiple actual Copyrights, like Melvin's, and also
those that just have 2 copies of the parrot one.)

Modified:
   trunk/t/codingstd/copyright.t

Modified: trunk/t/codingstd/copyright.t
==============================================================================
--- trunk/t/codingstd/copyright.t	Fri Mar 13 19:28:31 2009	(r37386)
+++ trunk/t/codingstd/copyright.t	Fri Mar 13 19:34:17 2009	(r37387)
@@ -7,7 +7,7 @@
 
 use lib qw( . lib ../lib ../../lib );
 use Parrot::Distribution;
-use Test::More tests => 2;
+use Test::More tests => 3;
 
 =head1 NAME
 
@@ -41,8 +41,13 @@
 my @all_files  = ( @c_files, @perl_files, @make_files );
 
 my @files = @ARGV ? <@ARGV> : @all_files;
-my ( @no_copyright_files, @bad_format_copyright_files );
+my ( @no_copyright_files,
+     @bad_format_copyright_files,
+     @duplicate_copyright_files
+);
 
+my $copyright_simple =
+    qr/Copyright \(C\) \d{4}/i;
 my $copyright_re =
     qr/Copyright \(C\) (?:\d{4}\-)?\d{4}, Parrot Foundation\.$/m;
 
@@ -55,15 +60,20 @@
     my $buf = $DIST->slurp($path);
 
     # does there exist a copyright statement at all?
-    if ( $buf !~ m{Copyright \(C\) \d{4}}m ) {
+    if ( $buf !~ $copyright_simple ) {
         push @no_copyright_files, $path;
         next;
     }
 
     # is the copyright text correct?
-    if ( ! ($buf =~ $copyright_re) ) {
+    # If so, remove it...
+    if ( ! ($buf =~ s/$copyright_re//) ) {
         push @bad_format_copyright_files, $path;
     }
+    # ... and then see if any other copyright notices exist.
+    elsif ($buf =~ $copyright_simple) {
+        push @duplicate_copyright_files, $path; 
+    }
 }
 
 # run the tests
@@ -97,6 +107,16 @@
         "To find the C<last-year-modified>, use a command such as:",
         "  svn log C<filename> | grep 'lines' | head -n 1"
         );
+
+    ok( !scalar(@duplicate_copyright_files), 'Duplicate Copyright statements' )
+        or diag(
+        join
+            $/ => "Duplicate copyright statement found in "
+            . scalar @duplicate_copyright_files
+            . " files:",
+        @duplicate_copyright_files,
+        "Please get copyright assigned to Parrot Foundation and remove alternate notice."
+        );
 }
 
 # Local Variables:


More information about the parrot-commits mailing list