~ubuntu-branches/ubuntu/precise/padre/precise

« back to all changes in this revision

Viewing changes to t/13-eol.t

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2010-05-08 09:17:22 UTC
  • mfrom: (1.2.1 upstream) (10.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100508091722-y6008jtk0ap6znyn
Tags: 0.60.ds1-3
rules: run tests with HOME=$fake_home to avoud failing when $HOME points
to a non-existent location. Closes: #579289

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
use strict;
2
 
use warnings;
3
 
use Test::More;
4
 
 
5
 
BEGIN {
6
 
        unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
7
 
                plan skip_all => 'Needs DISPLAY';
8
 
                exit 0;
9
 
        }
10
 
}
11
 
 
12
 
# Checks for UNIX end of lines (aka newlines)
13
 
use File::Find::Rule;
14
 
use t::lib::Padre;
15
 
use Padre::Util qw(newline_type);
16
 
 
17
 
my @files =
18
 
        File::Find::Rule->file->name( '*.pm', '*.pod', '*.pl', '*.p6', '*.t', '*.yml', '*.txt' )->in( 'lib', 't', 'share' );
19
 
@files = ( @files, 'Artistic', 'COPYING', 'Makefile.PL', 'Changes', 'padre.yml' );
20
 
 
21
 
plan( tests => scalar @files );
22
 
foreach my $file (@files) {
23
 
        my $eol = newline_type( slurp($file) );
24
 
        ok( ( $eol eq 'UNIX' ) || ( $eol eq 'None' ), "$file has UNIX-EOLs or none" );
25
 
}
26
 
 
27
 
######################################################################
28
 
# Support Functions
29
 
 
30
 
sub slurp {
31
 
        my $file = shift;
32
 
        open my $fh, '<', $file or die $!;
33
 
        binmode $fh;
34
 
        local $/ = undef;
35
 
        return <$fh>;
36
 
}