Index: t/codingstd/cppcomments.t =================================================================== --- t/codingstd/cppcomments.t (revision 13166) +++ t/codingstd/cppcomments.t (working copy) @@ -7,6 +7,7 @@ use lib qw( . lib ../lib ../../lib ); use Test::More tests => 1; +use Parrot::Distribution; =head1 NAME @@ -21,51 +22,30 @@ Checks that no source file in the distribution uses C++ style comments. -=head1 TODO - -Use Parrot::Distribution for looking for C-source files. - =cut -my @globs = qw( - compilers/ast/*.c - compilers/ast/*.h - compilers/imcc/*.c - compilers/imcc/*.h - include/parrot/*.h - include/parrot/oplib/*.h - src/*.c - src/charset/*.c - src/charset/*.h - src/dynoplibs/*.ops - src/dynpmc/*.pmc - src/encodings/*.c - src/encodings/*.h - src/io/*.c - src/io/*.h - src/jit/*/*.h - src/ops/*.ops - src/pmc/*.pmc - src/packfile/*.c -); +sub source_files { + my $dist = Parrot::Distribution->new; + return ( + map($_->files_of_type('C code'), $dist->c_source_file_directories), + map($_->files_of_type('C header'), $dist->c_header_file_directories), + ); +} my @comments; -foreach my $glob ( @globs ) { - foreach my $file ( glob $glob ) { - - open FILE, "<$file" or die "Can not open '$file' for reading!\n"; - foreach my $line ( ) { - next unless $line =~ m{//}; - next if $line =~ m{://}; # skip ftp:// http:// etc - next if $line =~ m{"//}; # skip printf("//= ") - - push @comments, "$file: $line" - } - close FILE; +foreach my $file ( source_files ) { + my $path = $file->path; + open(my $fh, q(<), $path) or die "Can not open '$path' for reading!\n"; + foreach my $line (<$fh>) { + next unless $line =~ m{//}; + next if $line =~ m{://}; # skip ftp:// http:// etc + next if $line =~ m{"//}; # skip printf("//= ") + push @comments, "$path: $line"; } } -ok( ! scalar(@comments), 'C++ style comments') -or diag( "C++ style comments found:\n@comments" ); +ok(!scalar(@comments), 'C++ style comments') + or diag("C++ style comments found:\n@comments"); +