don't rely on . in @INC in tests and stop using t::mod names
Graham Knop [Thu, 28 Jul 2016 20:53:20 +0000 (16:53 -0400)]
13 files changed:
t/mod/ModuleA.pm [new file with mode: 0644]
t/mod/ModuleB.pm [new file with mode: 0644]
t/mod/ModuleC.pm [moved from t/mod/c.pm with 71% similarity]
t/mod/ModuleCond.pm [new file with mode: 0644]
t/mod/ModuleD.pl [new file with mode: 0644]
t/mod/ModuleD.pm [new file with mode: 0644]
t/mod/a.pm [deleted file]
t/mod/b.pm [deleted file]
t/mod/cond.pm [deleted file]
t/mod/d.pl [deleted file]
t/mod/d.pm [deleted file]
t/pack.t
t/trace.t

diff --git a/t/mod/ModuleA.pm b/t/mod/ModuleA.pm
new file mode 100644 (file)
index 0000000..7df19ef
--- /dev/null
@@ -0,0 +1,6 @@
+package ModuleA;
+use ModuleB;
+
+$foo = "bar";
+
+1;
diff --git a/t/mod/ModuleB.pm b/t/mod/ModuleB.pm
new file mode 100644 (file)
index 0000000..aea2dc8
--- /dev/null
@@ -0,0 +1,3 @@
+package ModuleB;
+use ModuleC;
+1;
similarity index 71%
rename from t/mod/c.pm
rename to t/mod/ModuleC.pm
index d44639b..dd9670d 100644 (file)
@@ -1,4 +1,4 @@
-package t::mod::c;
+package ModuleC;
 
 sub xyz {
   shift()
diff --git a/t/mod/ModuleCond.pm b/t/mod/ModuleCond.pm
new file mode 100644 (file)
index 0000000..ef12ab6
--- /dev/null
@@ -0,0 +1,3 @@
+package ModuleCond;
+eval { require ModuleNothere };
+1;
diff --git a/t/mod/ModuleD.pl b/t/mod/ModuleD.pl
new file mode 100644 (file)
index 0000000..5def6ad
--- /dev/null
@@ -0,0 +1 @@
+use ModuleD;
diff --git a/t/mod/ModuleD.pm b/t/mod/ModuleD.pm
new file mode 100644 (file)
index 0000000..021901e
--- /dev/null
@@ -0,0 +1,4 @@
+package ModuleD;
+$INC{"ModuleForeign.pm"} = __FILE__;
+1;
+
diff --git a/t/mod/a.pm b/t/mod/a.pm
deleted file mode 100644 (file)
index 3d40685..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package t::mod::a;
-use t::mod::b;
-
-$foo = "bar";
-
-1;
diff --git a/t/mod/b.pm b/t/mod/b.pm
deleted file mode 100644 (file)
index 9127201..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package t::mod::b;
-use t::mod::c;
-1;
diff --git a/t/mod/cond.pm b/t/mod/cond.pm
deleted file mode 100644 (file)
index d4af160..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-package t::mod::cond;
-eval { require t::mod::nothere };
-1;
diff --git a/t/mod/d.pl b/t/mod/d.pl
deleted file mode 100644 (file)
index 7217002..0000000
+++ /dev/null
@@ -1 +0,0 @@
-use t::mod::d;
diff --git a/t/mod/d.pm b/t/mod/d.pm
deleted file mode 100644 (file)
index 53ddfc1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-package t::mod::d;
-$INC{"t/mod/foreign.pm"} = __FILE__;
-1;
-
index 55e5104..d5fa477 100644 (file)
--- a/t/pack.t
+++ b/t/pack.t
@@ -14,10 +14,10 @@ my $keep = $ENV{'FATPACKER_KEEP_TESTDIR'};
 
 my $cwd = getcwd;
 my $tempdir = tempdir('fatpacker-XXXXX', DIR => "$cwd/t", $keep ? (CLEANUP => 0) : (CLEANUP => 1));
-mkpath([<$tempdir/{lib,fatlib}/t/mod>]);
+mkpath([<$tempdir/{lib,fatlib}>]);
 
-for(<t/mod/*.pm>) {
-  copy $_, "$tempdir/lib/$_" or die "copy failed: $!";
+for (<t/mod/*.pm>) {
+  copy $_, "$tempdir/lib/".basename($_) or die "copy failed: $!";
 }
 
 chdir $tempdir;
@@ -40,9 +40,9 @@ chdir File::Spec->tmpdir;
 require $packed_file;
 
 {
-  require t::mod::a;
+  require ModuleA;
   no warnings 'once';
-  ok $t::mod::a::foo eq 'bar', "packed script works";
+  ok $ModuleA::foo eq 'bar', "packed script works";
 }
 
 {
@@ -53,11 +53,11 @@ require $packed_file;
     my @files = sort $INC[0]->files;
 
     is_deeply( \@files, [
-        't/mod/a.pm',
-        't/mod/b.pm',
-        't/mod/c.pm',
-        't/mod/cond.pm',
-        't/mod/d.pm',
+        'ModuleA.pm',
+        'ModuleB.pm',
+        'ModuleC.pm',
+        'ModuleCond.pm',
+        'ModuleD.pm',
     ], "\$INC[0]->files returned the files" );
 
 }
@@ -66,11 +66,11 @@ require $packed_file;
 if (my $testwith = $ENV{'FATPACKER_TESTWITH'}) {
   for my $perl (split ' ', $testwith) {
     my $out = system $perl, '-e',
-        q{alarm 5; require $ARGV[0]; require t::mod::a; exit($t::mod::a::foo eq 'bar' ? 0 : 1)}, $temp_fh;
+        q{alarm 5; require $ARGV[0]; require ModuleA; exit($ModuleA::foo eq 'bar' ? 0 : 1)}, $temp_fh;
     ok !$out, "packed script works with $perl";
 
     $out = system $perl, '-e',
-        q{alarm 5; require $ARGV[0]; exit( (sort $INC[0]->files)[0] eq 't/mod/a.pm' ? 0 : 1 )}, $temp_fh;
+        q{alarm 5; require $ARGV[0]; exit( (sort $INC[0]->files)[0] eq 'ModuleA.pm' ? 0 : 1 )}, $temp_fh;
     ok !$out, "\$INC[0]->files works with $perl";
 
   }
index 0d8191e..0d379a2 100644 (file)
--- a/t/trace.t
+++ b/t/trace.t
@@ -2,20 +2,20 @@ use strict;
 use warnings FATAL => 'all';
 use Test::More qw(no_plan);
 
-test_trace("t/mod/a.pm" => ("t/mod/b.pm", "t/mod/c.pm"));
-test_trace("t/mod/b.pm" => ("t/mod/c.pm"));
-test_trace("t/mod/c.pm" => ());
-test_trace("t/mod/d.pl" => ("t/mod/d.pm"));
+test_trace("t/mod/ModuleA.pm" => ("ModuleB.pm", "ModuleC.pm"));
+test_trace("t/mod/ModuleB.pm" => ("ModuleC.pm"));
+test_trace("t/mod/ModuleC.pm" => ());
+test_trace("t/mod/ModuleD.pl" => ("ModuleD.pm"));
 
 # Attempts to conditionally load a module that isn't present
-test_trace("t/mod/cond.pm" => ());
+test_trace("t/mod/ModuleCond.pm" => ());
 
 sub test_trace {
   my($file, @loaded) = @_;
   local $Test::Builder::Level = $Test::Builder::Level + 1;
 
   unlink "fatpacker.trace";
-  system($^X, "-Mblib", "-MApp::FatPacker::Trace", $file);
+  system($^X, "-Mblib", '-It/mod', "-MApp::FatPacker::Trace", $file);
 
   open my $trace, "<", "fatpacker.trace";
   my @traced = sort map { chomp; $_ } <$trace>;