Support not having a lib directory
[p5sagit/App-FatPacker.git] / t / pack_lib.t
diff --git a/t/pack_lib.t b/t/pack_lib.t
new file mode 100644 (file)
index 0000000..dde0f91
--- /dev/null
@@ -0,0 +1,43 @@
+#!perl
+use strict;
+use warnings FATAL => 'all';
+use Test::More;
+use File::Basename;
+use File::Copy;
+use File::Path;
+use File::Temp;
+
+sub test_with {
+    use_ok "App::FatPacker", "";
+    my $dir = shift;
+    my $tempdir = File::Temp->newdir;
+    mkpath([<$tempdir/$dir/t/mod>]);
+
+    for(<t/mod/*.pm>) {
+        copy $_, "$tempdir/$dir/$_" 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';
+    }
+}
+
+unless (caller()) {
+    plan 'no_plan';
+    test_with("lib");
+}