PageRenderTime 27ms CodeModel.GetById 14ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/Makefile.PL

http://github.com/http-engine/HTTP-Engine
Perl | 178 lines | 148 code | 27 blank | 3 comment | 20 complexity | 79b2b8d5e4abcdc6472ab14a035579b8 MD5 | raw file
  1use inc::Module::Install;
  2BEGIN
  3{
  4    eval { 
  5        die "not testing mod_perl" unless $ENV{TEST_MODPERL};
  6        require mod_perl2;
  7        require Apache::Test;
  8    };
  9    {
 10        no strict 'refs';
 11        *HAVE_MP = $@ ? sub { 0 } : sub { 1 };
 12    }
 13
 14    if (!$ENV{SHIPIT} && eval {
 15        require Moose  && Moose->VERSION(
 16            '0.73'
 17        ) && require MooseX::Types
 18    }) {
 19        *HAVE_MOOSE = sub { 1 };
 20    } else {
 21        *HAVE_MOOSE = sub { 0 };
 22    }
 23}
 24
 25if (HAVE_MP) {
 26    require Apache::TestMM;
 27    Apache::TestMM->import(qw(clean test));
 28}
 29
 30{
 31    no warnings 'redefine';
 32    *recommends_hack = $Module::Install::VERSION > 0.70 ?
 33        sub { recommends(@_); $_[0] } :
 34        \&recommends;
 35}
 36
 37name 'HTTP-Engine';
 38all_from 'lib/HTTP/Engine.pm';
 39
 40requires 'Any::Moose'    => '0.13';
 41requires 'Mouse'         => '0.62';
 42requires 'MouseX::Types' => '0.05';
 43requires 'Scalar::Util'  => 1.19;
 44
 45requires 'File::Copy'       => 0;
 46requires 'File::Spec::Unix' => 3.2701;
 47
 48requires 'CGI::Simple::Cookie' => 1.103;
 49requires 'HTTP::Body'          => '1.05';
 50requires 'HTTP::Headers::Fast' => 0.11;
 51requires 'URI'                 => 1.36;
 52
 53# prevent tests from failing with HTTP::Server::Simple is present, but
 54# but the version is too old. It has no real further dependencies anyway. 
 55requires 'HTTP::Server::Simple' => 0.35;
 56
 57features(
 58    'Interface::FCGI' => [
 59        -default => 0,
 60        recommends_hack('FCGI' => 0.67),
 61    ],
 62
 63    'Interface::ServerSimple' => [
 64        -default => 0,
 65        recommends_hack('HTTP::Server::Simple' => 0.34),
 66    ],
 67
 68    'Interface::Standalone' => [
 69        -default => 0,
 70        recommends_hack('Errno' => 1.0901),
 71        recommends_hack('IO::Socket::INET' => 1.31),
 72    ],
 73
 74    'Interface::Test' => [
 75        -default => 0,
 76        recommends_hack('IO::Scalar' => 2.110),
 77    ],
 78
 79    'Interface::POE' => [
 80        -default => 0,
 81        recommends_hack('POE' => '1.0003'),
 82        recommends_hack('POE::Filter::HTTPD' => 1.2387),
 83    ],
 84);
 85
 86my @tests;
 87if (HAVE_MP) {
 88    Apache::TestMM::filter_args();
 89    Apache::TestMM::generate_script('t/TEST');
 90    @tests = qw( t/*.t t/*/*.t t/modperl/basic.t t/modperl/whole.t );
 91} else {
 92    @tests = qw( t/*.t t/*/*.t );
 93    author_tests('xt');
 94}
 95
 96if (HAVE_MOOSE) {
 97    my $tests = 
 98        join ' ', (
 99            @tests,
100            (map {
101                my $t = $_;
102                $t =~ s/(?:basic|whole).t/*.t/;
103                $t =~ s{^t/}{t/moose/};
104                ($t eq 't/moose/*.t' || $t eq 't/moose/modperl/*.t') ? () : $t;
105            } @tests)
106        );
107    tests($tests);
108} else {
109    tests(join ' ', @tests);
110}
111
112test_requires 'YAML'; # Test::Base requires this
113test_requires 'Test::More';
114test_requires 'IO::Scalar';
115test_requires 'File::Temp' => '0.20';
116test_requires 'HTTP::Request::AsCGI';
117test_requires 'Test::SharedFork' => 0.11;
118test_requires 'Test::TCP' => 0.16;
119test_requires 'IO::Socket' => 1.30;
120test_requires 'IO::Socket::INET';
121test_requires 'IO::File' => 1.14;
122
123author_requires 'POE';
124author_requires 'Net::Server::Single';
125author_requires 'Moose';
126author_requires 'MooseX::Types';
127
128use_test_base;
129include_deps 'Test::TCP';
130auto_set_repository;
131WriteAll;
132
133# generate moose's test
134if (HAVE_MOOSE) {
135    $| = 1;
136    print "Generating tests with Moose: this could take up to minutes ";
137    my @testfiles;
138    require File::Find;
139    require File::Path;
140    require File::Spec;
141
142    File::Path::rmtree(File::Spec->catfile( 't', 'moose' ));
143
144    File::Find::find(
145        sub {
146            return if $File::Find::dir =~ /\./ || /^\./; # skip dot directory
147            return unless -f $_;
148
149            my @dirs = File::Spec->splitpath( $File::Find::dir );
150            while (!!!$dirs[0]) {
151                shift @dirs;
152            }
153            shift @dirs;
154            return if $dirs[0] eq 'xxx'; # skip to moose's test directory remover
155            push @testfiles, [ $File::Find::dir, File::Spec->catfile( 't', 'moose', @dirs ), $_ ];
156        }, 't'
157    );
158
159    for my $stuff (@testfiles) {
160        File::Path::mkpath($stuff->[1]);
161
162        my $from = File::Spec->catfile($stuff->[0], $stuff->[2]);
163        my $to   = File::Spec->catfile($stuff->[1], $stuff->[2]);
164
165       next if $from =~ /modperl.+post\.t$/;
166
167        open my $from_fh, '<', $from;
168        open my $to_fh, '>', $to;
169        if ($to =~ /\.t$/) {
170            print $to_fh "BEGIN { \$ENV{ANY_MOOSE} = 'Moose' }\n";
171        }
172
173        while (<$from_fh>) {
174            print $to_fh $_;
175        }
176    }
177    print "... done\n";
178}