2 use warnings FATAL => 'all';
3 use Test::More qw(no_plan);
7 use File::Temp qw/tempdir/;
13 my $keep = $ENV{'FATPACKER_KEEP_TESTDIR'};
16 my $tempdir = tempdir('fatpacker-XXXXX', DIR => "$cwd/t", $keep ? (CLEANUP => 0) : (CLEANUP => 1));
17 mkpath([<$tempdir/{lib,fatlib}>]);
20 copy $_, "$tempdir/lib/".basename($_) or die "copy failed: $!";
25 my $fp = App::FatPacker->new;
26 my $packed_file = "$tempdir/script";
27 open my $temp_fh, '>', $packed_file
28 or die "can't write to $packed_file: $!";
31 $fp->script_command_file;
36 # make sure we don't pick up things from our created dir
37 chdir File::Spec->tmpdir;
39 # Packed, now try using it:
45 ok $ModuleA::foo eq 'bar', "packed script works";
50 ok ref $INC[0], "\$INC[0] is a reference";
51 ok $INC[0]->can( "files" ), "\$INC[0] has a files method";
53 my @files = sort $INC[0]->files;
61 ], "\$INC[0]->files returned the files" );
66 if (my $testwith = $ENV{'FATPACKER_TESTWITH'}) {
67 for my $perl (split ' ', $testwith) {
68 my $out = system $perl, '-e',
69 q{alarm 5; require $ARGV[0]; require ModuleA; exit($ModuleA::foo eq 'bar' ? 0 : 1)}, $temp_fh;
70 ok !$out, "packed script works with $perl";
72 $out = system $perl, '-e',
73 q{alarm 5; require $ARGV[0]; exit( (sort $INC[0]->files)[0] eq 'ModuleA.pm' ? 0 : 1 )}, $temp_fh;
74 ok !$out, "\$INC[0]->files works with $perl";