Merge pull request #170 from perl-catalyst/haarg/no-dev-circ-deps
[catagits/Catalyst-Runtime.git] / t / lib / MakeTestApp.pm
CommitLineData
8ae46e98 1package MakeTestApp;
2use strict;
3use warnings;
4
5use Exporter 'import';
6use Cwd qw(abs_path);
7use File::Spec::Functions qw(updir catdir);
8use File::Basename qw(dirname);
9use File::Path qw(rmtree);
10use File::Copy::Recursive qw(dircopy);
11
12our @EXPORT = qw(make_test_app);
13
14our $root = abs_path(catdir(dirname(__FILE__), (updir) x 2));
15
16sub make_test_app {
17 my $tmp = "$root/t/tmp";
18 rmtree $tmp if -d $tmp;
19 mkdir $tmp;
20
21 # create a TestApp and copy the test libs into it
22 my $testapp = "$tmp/TestApp";
23 mkdir $testapp;
24
25 mkdir "$testapp/lib";
26 mkdir "$testapp/script";
27
28 for my $command (qw(CGI FastCGI Server)) {
29 my $script = "$testapp/script/testapp_\L$command\E.pl";
30 open my $fh, '>:raw', $script
31 or die "can't create $script: $!";
32 print $fh <<"END_CODE";
33#!/usr/bin/env perl
34
35use Catalyst::ScriptRunner;
36Catalyst::ScriptRunner->run('TestApp', '$command');
37
381;
39END_CODE
40 close $fh;
41 chmod 0755, $script;
42 }
43
44 open my $fh, '>:raw', "$testapp/cpanfile";
45 close $fh;
46
47 File::Copy::Recursive::dircopy( "$root/t/lib", "$testapp/lib" );
48
49 return $testapp;
50}
51
521;