3 use warnings FATAL => 'all';
4 use Test::More qw(no_plan);
8 use File::Temp qw/tempdir/;
12 BEGIN { use_ok "App::FatPacker", "" }
14 my $keep = $ENV{'FATPACKER_KEEP_TESTDIR'};
15 my $tempdir = tempdir($keep ? (CLEANUP => 0) : (CLEANUP => 1));
16 mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
19 copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
25 my $fp = App::FatPacker->new;
26 my $temp_fh = File::Temp->new;
28 $fp->script_command_file;
33 # make sure we don't pick up things from our created dir
34 chdir File::Spec->tmpdir;
36 # Packed, now try using it:
42 ok $t::mod::a::foo eq 'bar', "packed script works";
47 ok ref $INC[0], "\$INC[0] is a reference";
48 ok $INC[0]->can( "files" ), "\$INC[0] has a files method";
50 my @files = sort $INC[0]->files;
57 ], "\$INC[0]->files returned the files" );
62 if (my $testwith = $ENV{'FATPACKER_TESTWITH'}) {
63 for my $perl (split ' ', $testwith) {
64 my $out = system $perl, '-e',
65 q{alarm 5; require $ARGV[0]; require t::mod::a; exit($t::mod::a::foo eq 'bar' ? 0 : 1)}, $temp_fh;
66 ok !$out, "packed script works with $perl";
68 $out = system $perl, '-e',
69 q{alarm 5; require $ARGV[0]; exit( (sort $INC[0]->files)[0] eq 't/mod/a.pm' ? 0 : 1 )}, $temp_fh;
70 ok !$out, "\$INC[0]->files works with $perl";