# New Ticket Created by "Paul Cochrane" # Please include the string: [perl #40430] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40430 >
Hi, This patch renames the C code coda test and removes the Perl-specific code from the test (this code is now in the Perl code coda test). Regards, Paul files affected: t/codingstd/code_coda.t t/codingstd/c_code_coda.t
Index: t/codingstd/code_coda.t =================================================================== --- t/codingstd/code_coda.t (revision 14786) +++ t/codingstd/code_coda.t (working copy) @@ -1,114 +0,0 @@ -#! perl -# Copyright (C) 2006, The Perl Foundation. -# $Id$ - -use strict; -use warnings; - -use lib qw( . lib ../lib ../../lib ); -use Test::More tests => 2; -use Parrot::Distribution; - - -=head1 NAME - -t/codingstd/code_coda.t - checks for editor hint coda in source - -=head1 SYNOPSIS - - # test all files - % prove t/codingstd/code_coda.t - - # test specific files - % perl t/codingstd/code_coda.t src/foo.c include/parrot/bar.h - -=head1 DESCRIPTION - -Checks that all source files have the proper editor hints coda, -as specified in PDD07. - -=head1 SEE ALSO - -L<docs/pdds/pdd07_codingstd.pod> - -=cut - - -my $coda = <<'CODA'; -/* - * Local variables: - * c-file-style: "parrot" - * End: - * vim: expandtab shiftwidth=4: - */ -CODA - -my $DIST = Parrot::Distribution->new; -my @files = @ARGV ? @ARGV : source_files(); -my @no_coda; -my @extra_coda; - -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>; - } - - # append to the no_coda array if the code doesn't match - push @no_coda => "$path\n" - unless $buf =~ m{\Q$coda\E\n*\z}; - - # append to the extra_coda array if coda-like text appears more than once - my $vim_many =()= $buf =~ m{^ \s* \*? \s* vim: \s* $}gmx; - my $emacs_many =()= $buf =~ m{^ \s* \*? \s* Local variables: \s* $}gmx; - push @extra_coda => "$path\n" - if $vim_many > 1 || $emacs_many > 1; -} - -ok(!scalar(@no_coda), 'C code coda present') - or diag("C code coda missing in " - . scalar @no_coda . " files:[EMAIL PROTECTED]"); - -ok(!scalar(@extra_coda), 'C code coda appears only once') - or diag("C code coda repeating in " - . scalar @extra_coda . " 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), - ); -} - -sub perl_files { - return ( - map($_->files_of_type('Perl code'), $DIST->perl_file_directories), - ); -} - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: - Index: t/codingstd/c_code_coda.t =================================================================== --- t/codingstd/c_code_coda.t (revision 0) +++ t/codingstd/c_code_coda.t (revision 0) @@ -0,0 +1,108 @@ +#! perl +# Copyright (C) 2006, The Perl Foundation. +# $Id$ + +use strict; +use warnings; + +use lib qw( . lib ../lib ../../lib ); +use Test::More tests => 2; +use Parrot::Distribution; + + +=head1 NAME + +t/codingstd/code_coda.t - checks for editor hint coda in source + +=head1 SYNOPSIS + + # test all files + % prove t/codingstd/code_coda.t + + # test specific files + % perl t/codingstd/code_coda.t src/foo.c include/parrot/bar.h + +=head1 DESCRIPTION + +Checks that all source files have the proper editor hints coda, +as specified in PDD07. + +=head1 SEE ALSO + +L<docs/pdds/pdd07_codingstd.pod> + +=cut + + +my $coda = <<'CODA'; +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ +CODA + +my $DIST = Parrot::Distribution->new; +my @files = @ARGV ? @ARGV : source_files(); +my @no_coda; +my @extra_coda; + +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>; + } + + # append to the no_coda array if the code doesn't match + push @no_coda => "$path\n" + unless $buf =~ m{\Q$coda\E\n*\z}; + + # append to the extra_coda array if coda-like text appears more than once + my $vim_many =()= $buf =~ m{^ \s* \*? \s* vim: \s* $}gmx; + my $emacs_many =()= $buf =~ m{^ \s* \*? \s* Local variables: \s* $}gmx; + push @extra_coda => "$path\n" + if $vim_many > 1 || $emacs_many > 1; +} + +ok(!scalar(@no_coda), 'C code coda present') + or diag("C code coda missing in " + . scalar @no_coda . " files:[EMAIL PROTECTED]"); + +ok(!scalar(@extra_coda), 'C code coda appears only once') + or diag("C code coda repeating in " + . scalar @extra_coda . " 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), + ); +} + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: +