gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog devtools/testsuite/copyright_no...


From: Ann Barcomb
Subject: [Gnash-commit] gnash ChangeLog devtools/testsuite/copyright_no...
Date: Mon, 28 May 2007 08:31:13 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Ann Barcomb <ann>       07/05/28 08:31:13

Modified files:
        .              : ChangeLog 
Added files:
        devtools/testsuite: copyright_notices.t 

Log message:
        Because of John's recent mail concerning FSF copyright/license notes,
        I added a test which checks for potential problems with the copyright.
        
        It doesn't yet check for odd whitespace after the notice, but it does
        check if the copyright exists, if the file starts with a one-line 
comment
        describing the file, if 'You should have received...' begins a new
        paragraph, and if the copyright notice includes the current year.
        
        My thought was that perhaps at some moment when there's a minimal chance
        of commit conflicts I or someone else could use the test to identify 
        problem files and correct them. 

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3374&r2=1.3375
http://cvs.savannah.gnu.org/viewcvs/gnash/devtools/testsuite/copyright_notices.t?cvsroot=gnash&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3374
retrieving revision 1.3375
diff -u -b -r1.3374 -r1.3375
--- ChangeLog   27 May 2007 23:41:48 -0000      1.3374
+++ ChangeLog   28 May 2007 08:31:11 -0000      1.3375
@@ -1,3 +1,8 @@
+2007-05-27 Ann Barcomb <address@hidden>
+
+       * devtools/testsuite/copyright_notices.t: Added a script to look
+         for incorrect copyright notices.
+
 2007-05-27  Rob Savoye  <address@hidden>
 
        * macros/archflag.m4: Drop --with-gcc-arch, and use --with-cpu,

Index: devtools/testsuite/copyright_notices.t
===================================================================
RCS file: devtools/testsuite/copyright_notices.t
diff -N devtools/testsuite/copyright_notices.t
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ devtools/testsuite/copyright_notices.t      28 May 2007 08:31:12 -0000      
1.1
@@ -0,0 +1,126 @@
+#! perl
+
+use strict;
+use warnings;
+
+use FindBin qw/$Bin/;
+use lib $Bin.'/../lib';
+use Test::More tests => 1;
+use Gnash::Distribution;
+use Gnash::Utils qw/clean/;
+
+my $DIST = Gnash::Distribution->new;
+
+## Jerry Gay explained that this construction was needed because Windows
+## does not get @ARGV the same way as most systems.
+my @files = @ARGV 
+    ? ( $^O eq 'MSwin32' ? <@ARGV> : @ARGV )
+    : $DIST->get_cpp_language_files();
+
+my $year = (localtime())[5] + 1900;
+
+my @failures;
+FILE: foreach my $path (@files) {
+    open my $fh, '<', $path
+        or die "Cannot open '$path' for reading: $!\n";
+
+    ## Read in the entire file, as some of the cleaning spans lines
+    local $/ = undef;
+    my $entire_file = <$fh>;
+
+    my @reason;
+
+    ## If there is no copyright notice, skip other checks
+    if ($entire_file !~ m|This program is free software; you can|) {
+        push @failures => "$path:\n\t* Copyright notice is missing.\n";
+        close $fh;
+        next FILE;
+    }
+
+    ## 'You should have received a copy of the GNU General Public License
+    ## along with the program; see the file COPYING.' should begin a new
+    ## paragraph.
+    if ($entire_file =~ m|details.\s+[*/]+\s+You|s) {
+        push @reason, "* 'You should have received...' does not ".
+          "begin a new paragraph."
+    }
+
+    ## Each file should start with a one-line comment describing it.
+    my ($fn) = $path =~ m|([^/\\]+)$|;
+    if ($entire_file !~ m|^\s*//\s+$fn|is) {
+        push @reason, "* Missing intro comment with filename and description."
+    }
+
+    ## There should be no unusual whitespace before the CVS tag.
+    # TODO (I haven't thought of a good way to check for this)
+
+    ## Copyright notices should include the current year
+    if ($entire_file !~ m|Copyright \(C\)[,\s\d]+$year|is) {
+        push @reason, "* Copyright does not extent to $year.";
+    }
+
+    push @failures => "$path:\n\t". (join "\n\t", @reason) ."\n" if (@reason);
+    close $fh;
+}
+
+ok( !scalar(@failures), "Incorrect GNU copyright notice" )
+    or diag("Incorrect GNU copyright notice found in ".
+    scalar @failures." files:address@hidden");
+
+=head1 NAME
+
+devtools/testsuite/copyright_notices.t - look for incorrect copyright notices
+
+=head1 SYNOPSIS
+
+    # test all files
+    % prove devtools/testsuite/copyright_notices.t
+
+    # test specific files
+    % perl devtools/testsuite/copyright_notices.t recently/modified/file
+
+=head1 DESCRIPTION
+
+This test looks for errors in the copyright notices in all C++ files.  
+Specifically, it looks for:
+
+=over 4
+
+=item * That there is a copyright notice
+
+=item * Instances where the line 'You should have received...' does not
+begin a new paragraph
+
+=item * Files which don't begin with a comment which includes the filename
+and a description of the file
+
+=item * Copyright notices which don't include the current year
+
+=back
+
+A test to check for odd whitespace after the copyright notice and before
+the CVS Id tag should be added.
+
+=head1 AUTHORS
+
+Ann Barcomb <address@hidden>, based upon ideas from the Parrot
+L<http://http://dev.perl.org/perl6/> test suite.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2007 Free Software Foundation, Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+=cut




reply via email to

[Prev in Thread] Current Thread [Next in Thread]