# New Ticket Created by  "John J. Trammell" 
# Please include the string:  [perl #39746]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=39746 >


New "technical debt" test to look for FIXME, TODO, and XXX markers in
C code and headers.

-- 
He's dead, Jim.  You get his tricorder, I'll get his wallet.
--- MANIFEST    2006-07-06 15:37:58.000000000 -0500
+++ MANIFEST.new        2006-07-06 15:33:23.000000000 -0500
@@ -980,6 +980,7 @@
 t/examples/subs.t                                 []
 t/examples/namespace.t                            []
 t/codingstd/cppcomments.t                         []
+t/codingstd/fixme.t                               []
 config/inter/shlibs.pm                            []
 config/inter/types.pm                             []
 config/inter/encoding.pm                          []
#! perl
# Copyright (C) 2001-2006, The Perl Foundation.
# $Id$

use strict;
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
use Parrot::Distribution;


=head1 NAME

t/codingstd/fixme.t - checks for "FIXME" and similar notes in C source and 
headers

=head1 SYNOPSIS

    % prove t/codingstd/fixme.t

=head1 DESCRIPTION

Checks that no C source or header file in the distribution contains the
following strings:

    FIXME
    TODO
    XXX

=cut


my @files = @ARGV ? @ARGV : source_files();

plan tests => scalar @files;

foreach my $file (@files) {
    open FILE, "<$file" or die "Unable to open '$file' for reading: $!";

    my @matches;
    while (<FILE>) {
        next unless /(FIXME|XXX|TODO)/;
        push @matches, "file '$file', line $.: $1\n";
    }
    close FILE;

    is(scalar(@matches), 0, "file '$file' has no FIXME strings")
      or diag(@matches);
}

sub source_files {
    my $dist = Parrot::Distribution->new;
    return map { $_->path } (
        map($_->files_of_type('C code'),   $dist->c_source_file_directories),
        map($_->files_of_type('C header'), $dist->c_header_file_directories),
    );
}

Reply via email to