1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
#!/usr/bin/perl -w
use strict;
use Test::Strict;
use File::Temp qw( tempdir tempfile );
my $HAS_WIN32 = 0;
if ($^O =~ /Win|Dos/i) { # Load Win32 if we are under Windows and if module is available
eval q{ use Win32 };
if ($@) {
warn "Optional module Win32 missing, consider installing\n";
}
else {
$HAS_WIN32 = 1;
}
}
##
## This should check all perl files in the distribution
## including this current file, the Makefile.PL etc.
## and check for "use strict;" and syntax ok
##
all_perl_files_ok();
strict_ok( $0, "got strict" );
syntax_ok( $0, "syntax" );
syntax_ok( 'Test::Strict' );
strict_ok( 'Test::Strict' );
warnings_ok( $0 );
my $warning_file1 = make_warning_file1();
warnings_ok( $warning_file1 );
my $warning_file2 = make_warning_file2();
warnings_ok( $warning_file2 );
my $warning_file3 = make_warning_file3();
warnings_ok( $warning_file3 );
my $warning_file4 = make_warning_file4();
warnings_ok( $warning_file4 );
my $warning_file5 = make_warning_file5();
warnings_ok( $warning_file5 );
{
my ($warnings_files_dir, $file_to_skip) = make_warning_files();
local $Test::Strict::TEST_WARNINGS = 1;
local $Test::Strict::TEST_SKIP = [ $file_to_skip ];
all_perl_files_ok( $warnings_files_dir );
}
sub make_warning_file1 {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pL' );
print $fh <<'DUMMY';
#!/usr/bin/perl -w
print "hello world";
DUMMY
return $HAS_WIN32 ? Win32::GetLongPathName($filename) : $filename;
}
sub make_warning_file2 {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pL' );
print $fh <<'DUMMY';
use warnings FATAL => 'all' ;
print "Hello world";
DUMMY
return $HAS_WIN32 ? Win32::GetLongPathName($filename) : $filename;
}
sub make_warning_file3 {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' );
print $fh <<'DUMMY';
use strict;
use warnings::register ;
print "Hello world";
DUMMY
return $HAS_WIN32 ? Win32::GetLongPathName($filename) : $filename;
}
sub make_warning_file4 {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' );
print $fh <<'DUMMY';
use Mouse ;
print "Hello world";
DUMMY
return $HAS_WIN32 ? Win32::GetLongPathName($filename) : $filename;
}
sub make_warning_file5 {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh, $filename) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' );
print $fh <<'DUMMY';
use Moose;
print "Hello world";
DUMMY
return $HAS_WIN32 ? Win32::GetLongPathName($filename) : $filename;
}
sub make_warning_files {
my $tmpdir = tempdir( CLEANUP => 1 );
my ($fh1, $filename1) = tempfile( DIR => $tmpdir, SUFFIX => '.pm' );
print $fh1 <<'DUMMY';
use strict;
use warnings::register ;
print "Hello world";
DUMMY
my ($fh2, $filename2) = tempfile( DIR => $tmpdir, SUFFIX => '.pl' );
print $fh2 <<'DUMMY';
#!/usr/bin/perl -vw
use strict;
print "Hello world";
DUMMY
my ($fh3, $filename3) = tempfile( DIR => $tmpdir, SUFFIX => '.pl' );
print $fh3 <<'DUMMY';
use strict;
local $^W = 1;
print "Hello world";
DUMMY
my ($fh4, $filename4) = tempfile( DIR => $tmpdir, SUFFIX => '.pl' );
print $fh4 <<'DUMMY';
#!/usr/bin/perl -Tw
use strict;
print "Hello world";
DUMMY
return ($tmpdir, $HAS_WIN32 ? Win32::GetLongPathName($filename3) : $filename3);
}
|