Add a test for packing
[p5sagit/App-FatPacker.git] / t / pack.t
1 #!perl
2 use strict;
3 use warnings FATAL => 'all';
4 use Test::More qw(no_plan);
5 use File::Basename;
6 use File::Copy;
7 use File::Path;
8 use File::Temp;
9
10 BEGIN { use_ok "App::FatPacker", "" }
11
12 my $tempdir = File::Temp->newdir;
13 mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
14
15 for(<t/mod/*.pm>) {
16   copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
17 }
18
19 chdir $tempdir;
20
21 my $fp = App::FatPacker->new;
22 my $temp_fh = File::Temp->new;
23 select $temp_fh;
24 $fp->script_command_file;
25 print "1;\n";
26 select STDOUT;
27 close $temp_fh;
28
29 # Packed, now try using it:
30 require $temp_fh;
31
32 {
33   require t::mod::a;
34   no warnings 'once';
35   ok $t::mod::a::foo eq 'bar';
36 }