Add a test for packing
David Leadbeater [Sun, 5 Feb 2012 12:30:08 +0000 (13:30 +0100)]
t/mod/a.pm
t/pack.t [new file with mode: 0644]

index c119640..3d40685 100644 (file)
@@ -1,3 +1,6 @@
 package t::mod::a;
 use t::mod::b;
+
+$foo = "bar";
+
 1;
diff --git a/t/pack.t b/t/pack.t
new file mode 100644 (file)
index 0000000..4d98b0b
--- /dev/null
+++ b/t/pack.t
@@ -0,0 +1,36 @@
+#!perl
+use strict;
+use warnings FATAL => 'all';
+use Test::More qw(no_plan);
+use File::Basename;
+use File::Copy;
+use File::Path;
+use File::Temp;
+
+BEGIN { use_ok "App::FatPacker", "" }
+
+my $tempdir = File::Temp->newdir;
+mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
+
+for(<t/mod/*.pm>) {
+  copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
+}
+
+chdir $tempdir;
+
+my $fp = App::FatPacker->new;
+my $temp_fh = File::Temp->new;
+select $temp_fh;
+$fp->script_command_file;
+print "1;\n";
+select STDOUT;
+close $temp_fh;
+
+# Packed, now try using it:
+require $temp_fh;
+
+{
+  require t::mod::a;
+  no warnings 'once';
+  ok $t::mod::a::foo eq 'bar';
+}