this is too noisy as ~700 tests. please convert it to one test, like the
other coding standard tests.
Ok.  Have changed it to be the same as the other coding standard
tests.  See attached patch.

also, it should apply to perl files, as well. in fact, it should
probably apply to most files in MANIFEST and MANIFEST.skip, except for a
few where the spaces are required (like some test data files.) however,
i'd accept this patch if it were extended only to cover the perl files.
Actually, I'm going to go with Will on this one.  At present all of
the coding standard tests except for perlcritic.t just test the
C-language files (.c, .h, .y, .l, .pmc, and if the patch gets in .ops)
whereas perlcritic tests just the Perl-specific stuff.  I think this
separation of responsibilities is a good thing, so have not included
Perl files in the attached patch.

thanks for your hard work!
No worries!  It's a pleasure to be able to help :-)  I hope my changes
are helping the code quality of parrot.

Regards,

Paul
Index: MANIFEST
===================================================================
--- MANIFEST	(revision 14955)
+++ MANIFEST	(working copy)
@@ -2449,6 +2449,7 @@
 t/codingstd/linelength.t                                    []
 t/codingstd/perlcritic.t                                    []
 t/codingstd/tabs.t                                          []
+t/codingstd/trailing_space.t                                []
 t/compilers/imcc/imcpasm/cfg.t                              []
 t/compilers/imcc/imcpasm/opt0.t                             []
 t/compilers/imcc/imcpasm/opt1.t                             []
Index: t/codingstd/trailing_space.t
===================================================================
--- t/codingstd/trailing_space.t	(revision 0)
+++ t/codingstd/trailing_space.t	(revision 0)
@@ -0,0 +1,99 @@
+#! perl
+# Copyright (C) 2006, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+use lib qw( . lib ../lib ../../lib );
+use Parrot::Distribution;
+use Test::More tests => 1;
+
+=head1 NAME
+
+t/codingstd/trailing_space.t - checks for superfluous trailing space or tab characters
+
+=head1 SYNOPSIS
+
+    # test all files
+    % prove t/codingstd/trailing_space.t
+
+    # test specific files
+    % perl t/codingstd/trailing_space.t src/foo.c include/parrot/bar.h
+
+=head1 DESCRIPTION
+
+Checks that files don't have trailing space or tab characters between the
+last nominal character on the line and the end of line character.
+
+=head1 SEE ALSO
+
+L<docs/pdds/pdd07_codingstd.pod>
+
+=cut
+
+my $DIST = Parrot::Distribution->new;
+
+my @files = @ARGV ? @ARGV : source_files();
+my @failed_files;
+
+foreach my $file (@files) {
+    my $buf;
+    my $path;
+
+    ## get the full path of the file
+    # if we have command line arguments, the file is the full path
+    if (@ARGV) {
+        $path = $file;
+    }
+
+    # otherwise, use the relevant Parrot:: path method
+    else {
+        $path = $file->path;
+    }
+
+    # slurp in the file
+    open( my $fh, '<', $path )
+        or die "Cannot open '$path' for reading: $!\n";
+    {
+        local $/;
+        $buf = <$fh>;
+    }
+
+    if ($buf =~ m{.?[ \t]+$}m) {
+        push @failed_files, $path;
+    }
+}
+
+# check the file
+ok( !scalar(@failed_files), 'No trailing spaces or tabs' )
+    or diag( "Trailing space or tab char found in " .  
+        scalar @failed_files .  " files:[EMAIL PROTECTED]" );
+
+exit;
+
+sub source_files {
+    return (
+        map( $_->files_of_type('C code'),
+            $DIST->c_source_file_directories ),
+
+        map( $_->files_of_type('C header'),
+            $DIST->c_header_file_directories ),
+
+        map( $_->files_of_type('PMC code'),
+            $DIST->pmc_source_file_directories ),
+
+        map( $_->files_of_type('Yacc file'),
+            $DIST->yacc_source_file_directories ),
+
+        map( $_->files_of_type('Lex file'),
+            $DIST->lex_source_file_directories ),
+    );
+}
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to