still requires perl 5.8; 5.6 only works for the fatpacked scripts, not the fatpacking...
[p5sagit/App-FatPacker.git] / t / pack.t
CommitLineData
edff3fdc 1#!perl
2use strict;
3use warnings FATAL => 'all';
4use Test::More qw(no_plan);
5use File::Basename;
6use File::Copy;
7use File::Path;
55044309 8use File::Temp qw/tempdir/;
8a3a89c9 9use Cwd;
edff3fdc 10
11BEGIN { use_ok "App::FatPacker", "" }
12
55044309 13my $keep = $ENV{'FATPACKER_KEEP_TESTDIR'};
14my $tempdir = tempdir($keep ? (CLEANUP => 0) : (CLEANUP => 1));
edff3fdc 15mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
16
17for(<t/mod/*.pm>) {
18 copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
19}
20
8a3a89c9 21my $cwd = getcwd;
edff3fdc 22chdir $tempdir;
23
24my $fp = App::FatPacker->new;
25my $temp_fh = File::Temp->new;
26select $temp_fh;
27$fp->script_command_file;
28print "1;\n";
29select STDOUT;
30close $temp_fh;
31
32# Packed, now try using it:
33require $temp_fh;
34
35{
36 require t::mod::a;
37 no warnings 'once';
38 ok $t::mod::a::foo eq 'bar';
39}
8a3a89c9 40
41# moving away from the dir so it could be deleted
42chdir $cwd;
55044309 43