use Cwd (core) to allow pruning tmp dirs in test
[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 use Cwd;
10
11 BEGIN { use_ok "App::FatPacker", "" }
12
13 my $tempdir = File::Temp->newdir;
14 mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
15
16 for(<t/mod/*.pm>) {
17   copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
18 }
19
20 my $cwd = getcwd;
21 chdir $tempdir;
22
23 my $fp = App::FatPacker->new;
24 my $temp_fh = File::Temp->new;
25 select $temp_fh;
26 $fp->script_command_file;
27 print "1;\n";
28 select STDOUT;
29 close $temp_fh;
30
31 # Packed, now try using it:
32 require $temp_fh;
33
34 {
35   require t::mod::a;
36   no warnings 'once';
37   ok $t::mod::a::foo eq 'bar';
38 }
39
40 # moving away from the dir so it could be deleted
41 chdir $cwd;