add and change NEWS for 2.8.0 release
[parrot.git] / t / codingstd / c_todo.t
blob29e175b7628e916dbea496a46da77d31f533b424
1 #! perl
2 # Copyright (C) 2006-2009, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( . lib ../lib ../../lib );
8 use Test::More tests => 1;
9 use Parrot::Distribution;
11 =head1 NAME
13 t/codingstd/c_todo.t - checks for "FIXME" and similar notes in C source and headers
15 =head1 SYNOPSIS
17     # test all files
18     % prove t/codingstd/c_todo.t
20     # test specific files
21     % perl t/codingstd/c_todo.t src/foo.c include/parrot/bar.h
23 =head1 DESCRIPTION
25 Checks that no C source or header file in the distribution contains the
26 following strings:
28     FIXME
29     TODO
30     XXX
32 =head1 SEE ALSO
34 L<docs/pdds/pdd07_codingstd.pod>
36 =cut
38 my $DIST = Parrot::Distribution->new;
39 my @files = @ARGV ? <@ARGV> : $DIST->get_c_language_files();
40 my @fixme;
41 my %failed_files;
43 foreach my $file (@files) {
45     # if we have command line arguments, the file is the full path
46     # otherwise, use the relevant Parrot:: path method
47     my $path = @ARGV ? $file : $file->path;
49     open my $fh, '<', $path
50         or die "Cannot open '$path' for reading: $!\n";
52     while (<$fh>) {
53         next unless /(FIXME|XXX|TODO)/;
55         push @fixme, "file '$path', line $.: $1\n";
56         $failed_files{$path}++;
57     }
58     close $fh;
61 my $num_failed_files = scalar keys %failed_files;
62 TODO: {
63     local $TODO = scalar(@fixme) . ' todos remain';
65 ok( !scalar(@fixme), 'FIXME strings' )
66     or diag( "FIXME strings found in "
67         . scalar @fixme
68         . " instances in "
69         . $num_failed_files
70         . " files:\n@fixme" );
73 # Local Variables:
74 #   mode: cperl
75 #   cperl-indent-level: 4
76 #   fill-column: 100
77 # End:
78 # vim: expandtab shiftwidth=4: