7
use lib $Bin.'/../lib';
8
use Test::More tests => 1;
9
use Gnash::Distribution;
10
use Gnash::Utils qw/clean/;
12
my $DIST = Gnash::Distribution->new;
14
## Jerry Gay explained that this construction was needed because Windows
15
## does not get @ARGV the same way as most systems.
17
? ( $^O eq 'MSwin32' ? <@ARGV> : @ARGV )
18
: $DIST->get_cpp_language_files();
20
my $year = (localtime())[5] + 1900;
23
FILE: foreach my $path (@files) {
24
open my $fh, '<', $path
25
or die "Cannot open '$path' for reading: $!\n";
27
## Read in the entire file, as some of the cleaning spans lines
29
my $entire_file = <$fh>;
34
## If there is no copyright notice, skip other checks
35
if ($entire_file !~ m|This program is free software; you can|) {
36
push @failures => "$path:\n\t* Copyright notice is missing.\n";
40
## 'You should have received a copy of the GNU General Public License
41
## along with the program; see the file COPYING.' should begin a new
43
if ($entire_file =~ m|details.\s+[*/]+\s+You|s) {
44
push @reason, "* 'You should have received...' does not ".
45
"begin a new paragraph."
48
## Each file should start with a one-line comment describing it.
49
my ($fn) = $path =~ m|([^/\\]+)$|;
50
if ($entire_file !~ m|^\s*//\s+$fn|is) {
51
push @reason, "* Missing intro comment with filename and description."
54
## There should be no unusual whitespace before the CVS tag.
55
# TODO (I haven't thought of a good way to check for this)
57
## Copyright notices should include the current year
58
if ($entire_file !~ m|Copyright \(C\)[,\s\d]+$year|is) {
59
push @reason, "* Copyright does not extend to $year.";
62
push @failures => "$path:\n\t". (join "\n\t", @reason) ."\n" if (@reason);
65
ok( !scalar(@failures), "Incorrect GNU copyright notice" )
66
or diag("Incorrect GNU copyright notice found in ".
67
scalar @failures." files:\n@failures");
73
devtools/testsuite/copyright_notices.t - look for incorrect copyright notices
78
% prove devtools/testsuite/copyright_notices.t
81
% perl devtools/testsuite/copyright_notices.t recently/modified/file
85
This test looks for errors in the copyright notices in all C++ files.
86
Specifically, it looks for:
90
=item * That there is a copyright notice
92
=item * Instances where the line 'You should have received...' does not
95
=item * Files which don't begin with a comment which includes the filename
96
and a description of the file
98
=item * Copyright notices which don't include the current year
102
A test to check for odd whitespace after the copyright notice and before
103
the CVS Id tag should be added.
107
Ann Barcomb <kudra@domaintje.com>, based upon ideas from the Parrot
108
L<http://http://dev.perl.org/perl6/> test suite.
112
Copyright (C) 2007 Free Software Foundation, Inc.
114
This program is free software; you can redistribute it and/or modify
115
it under the terms of the GNU General Public License as published by
116
the Free Software Foundation; either version 3 of the License, or
117
(at your option) any later version.
119
This program is distributed in the hope that it will be useful,
120
but WITHOUT ANY WARRANTY; without even the implied warranty of
121
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
122
GNU General Public License for more details.
123
You should have received a copy of the GNU General Public License
124
along with this program; if not, write to the Free Software
125
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA