chiark / gitweb /
exercise the C client a bit from tests
[disorder] / scripts / check
CommitLineData
460b9539 1#! /usr/bin/perl -w
2#
3# This file is part of DisOrder.
4# Copyright (C) 2005, 2006 Richard Kettlewell
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful, but
12# WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14# General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19# USA
20#
21
22use strict;
23
24my $year;
25my %checked = ();
26my %removed = ();
27my $prefix = -e ".src" ? ".src/" : "";
28my $what = "";
29my $original;
30my @exceptions;
31my %exceptions;
32my %missing = ();
33
34open(F, "<${prefix}scripts/copyright.exceptions") or die "$0: scripts/copyright.exceptions: $!";
35chomp(@exceptions = <F>);
36%exceptions = map(($_, 1), grep !/^\#/, @exceptions);
37
38opendir(D, "${prefix}ChangeLog.d") or die "$0: ChangeLog.d: $!\n";
39for my $dir (readdir D) {
40 next if $dir =~ /cvs/;
41 open(C, "<${prefix}ChangeLog.d/$dir") or die "$0: ChangeLog.d/$dir: $!\n";
42 while(defined($_ = <C>)) {
43 if(/^(\d{4})-\d{2}-\d{2}/) {
44 $year = $1;
45 }
46 if(/^\s+(modified|removed|renamed) files:$/) {
47 $what = $1;
48 next;
49 }
50 if(/^\s*$/) {
51 $what = "";
52 }
53 if($what eq 'modified') {
54 my @files = split(/\s+/, $_);
55 for my $file (@files) {
56 next if exists $checked{"$file-$year"};
57 next if $file =~ /^ChangeLog\.d/;
58 next if ! -e "$prefix$file";
59 open(INPUT, "<$prefix$file") or die "$0: $prefix$file: $!\n";
60 my $good = 0;
61 while(defined(my $line = <INPUT>)) {
62 if($line =~ /Copyright.*$year/i) {
63 $good = 1;
64 last;
65 }
66 }
67 close INPUT;
68 $checked{"$file-$year"} = $good;
69 $missing{"$file: missing $year"} = 1
70 if !$good && !exists $exceptions{$file};
71 }
72 }
73 }
74}
75
76print map("$_\n", sort keys %missing);
77