From: David Leadbeater <dgl@dgl.cx>
Date: Sun, 5 Feb 2012 12:30:08 +0000 (+0100)
Subject: Add a test for packing
X-Git-Tag: v0.9.7~18
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=edff3fdce761cadb45de0febaa25e099ef3f12e1;p=p5sagit%2FApp-FatPacker.git

Add a test for packing
---

diff --git a/t/mod/a.pm b/t/mod/a.pm
index c119640..3d40685 100644
--- a/t/mod/a.pm
+++ b/t/mod/a.pm
@@ -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
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';
+}