# New Ticket Created by "Paul Cochrane"
# Please include the string: [perl #40370]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=40370 >
Hi,
Attached is a patch for the code_coda.t test. The test now accepts
files passed in at the command line as advertised, and the regular
expression check has been fixed (I won't say improved as I think it
could be better, but it matches the coda at the end of the C files
now). Included in the regular expression is a somewhat more pedantic
version of the coda check, but I've commented this one out as I don't
know how picky people want to be (in other words, hack the patch at
will).
Files affected:
t/codingstd/code_coda.t
Regards,
Paul
Index: t/codingstd/code_coda.t
===================================================================
--- t/codingstd/code_coda.t (revision 14668)
+++ t/codingstd/code_coda.t (working copy)
@@ -38,27 +38,51 @@
my @files = @ARGV ? @ARGV : source_files();
my @comments;
+# process all files given to the script
foreach my $file ( @files ) {
my $buf;
- my $path = $file->path;
+ my $path;
+
+ ## get the full path of the file
+ # if we have command line arguments, the file is the full path
+ if (@ARGV > 0) {
+ $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 comments array if the code doesn't match
push @comments => "$path\n"
- unless $buf =~ m{\Q
-/*
- * Local variables:
- * c-file-style: "parrot"
- * End:
- * vim: expandtab shiftwidth=4:
- */\E
- \n* \z
+ unless $buf =~ m{
+#/ \* \s*
+#\* [ ] Local [ ] variables: \s*
+#\* [ ] [ ] [ ] c-file-style: [ ] "parrot" \s*
+#\* [ ] End: \s*
+#\* [ ] vim: [ ] expandtab [ ] shiftwidth=4: \s*
+#\* /
+#\n* \z
+/ \* \s*
+ \* \s* Local \s* variables: \s*
+ \* \s* c-file-style: \s* "parrot" \s*
+ \* \s* End: \s*
+ \* \s* vim: \s* expandtab \s* shiftwidth=4: \s*
+ \* /
+\n* \z
}x;
+
}
+
ok(!scalar(@comments), 'C code coda')
or diag("C code coda missing in ".scalar @comments." files:[EMAIL PROTECTED]");