Amos and Chris,

Thanks for the feedback!  I've updated the patch to use C<require>
instead of C<use>, and it is attached to this email.

Further to my question:

so do C<eval { use My::Class; };> and C<eval "use My::Class;";> get
evaluated at different times?  I'm trying to understand why one
generates a compile-time error, whereas the other generates the
expected output (i.e. skips the tests and supplies the reason) but
that the docs say they are (almost) the same thing.

Regards,

Paul
Index: MANIFEST
===================================================================
--- MANIFEST	(revision 14998)
+++ MANIFEST	(working copy)
@@ -2450,6 +2450,7 @@
 t/codingstd/cppcomments.t                                   []
 t/codingstd/cuddled_else.t                                  []
 t/codingstd/fixme.t                                         []
+t/codingstd/line_endings.t                                  []
 t/codingstd/linelength.t                                    []
 t/codingstd/perlcritic.t                                    []
 t/codingstd/tabs.t                                          []
Index: t/codingstd/line_endings.t
===================================================================
--- t/codingstd/line_endings.t	(revision 0)
+++ t/codingstd/line_endings.t	(revision 0)
@@ -0,0 +1,102 @@
+#! perl
+# Copyright (C) 2006, The Perl Foundation.
+# $Id$
+
+use strict;
+use warnings;
+
+use lib qw( . lib ../lib ../../lib );
+use Test::More;
+use ExtUtils::Manifest qw(maniread);
+
+# skip the tests if SVN::Client isn't installed
+BEGIN {
+    eval { require SVN::Client; };
+    if ($@) {
+        plan skip_all => 'SVN::Client not installed';
+    }
+}
+
+# set up how many tests to run
+plan tests => 1;
+
+=head1 NAME
+
+t/codingstd/line_endings.t - checks for DOS line endings in text files
+
+=head1 SYNOPSIS
+
+    # test all files
+    % prove t/codingstd/line_endings.t
+
+    # test specific files
+    % perl t/codingstd/line_endings.t src/foo.c include/parrot/bar.h
+
+=head1 DESCRIPTION
+
+Checks that text files do not have DOS (CRLF) line endings.  Instead, they
+should have Unix (CR) line endings.
+
+=head1 SEE ALSO
+
+L<docs/pdds/pdd07_codingstd.pod>
+
+=cut
+
+my @files = @ARGV ? @ARGV : source_files();
+my @dos_files;
+
+foreach my $file (@files) {
+    my $buf;
+
+    # slurp in the file
+    open( my $fh, '<', $file )
+        or die "Cannot open '$file' for reading: $!\n";
+    {
+        local $/;
+        $buf = <$fh>;
+    }
+
+    # append to the dos_files array if the code matches
+    push @dos_files => "$file\n"
+        if $buf =~ m{\r$}m;
+}
+
+ok( !scalar(@dos_files), 'Line endings correct' )
+    or diag( "DOS line ending found in " . scalar @dos_files . " files:[EMAIL PROTECTED]" );
+
+sub source_files
+{
+    my $client = SVN::Client->new();
+    my $manifest = maniread('MANIFEST');
+    my @test_files;
+    # grab names of files to test (except binary files)
+    foreach my $filename ( sort keys %$manifest ) {
+        # try to read the svn:mime-type property of the file
+        my $prop_ref = $client->propget("svn:mime-type", $filename, "WORKING", 0);
+
+        # if we have no mime-type property set or the mime-type is text/*
+        # then the file is text (this is the assumption used by subversion)
+        my $prop = $prop_ref->{$filename};
+        # of the mime-type property is undefined, append to the file list
+        if (!defined $prop) {
+            push @test_files, $filename;
+        }
+        else {
+            # if we know we have a text file, append it
+            push @test_files, $filename
+                if ($prop =~ m{text});
+        }
+    }
+
+    return @test_files;
+}
+
+exit;
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to