only include mods that match their filename in the fatpack
skaufman [Fri, 17 Jul 2015 21:03:28 +0000 (21:03 +0000)]
Changes
lib/Object/Remote/FatNode.pm
t/fatnode.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 094194d..2597522 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+  - Skip non-primary modules in a file to ensure we generate a sane fatpack
+
 0.003004 - 2014-10-04
   - Explicitly load Moo::HandleMoose::_TypeMap since it isn't loaded sans
     ithreads but we don't know if the foreign perl requires it
index fe07f29..8b143b8 100644 (file)
@@ -47,9 +47,16 @@ $command =~ s/\n/ /g;
 chomp(my @inc = qx($command));
 
 my %exclude = map { $_ => 1 } @exclude_mods;
-my %mods = reverse @inc;
+
 my %file_names = @inc;
 
+# only include mods that match the filename,
+# ie ones that will succeed with a require $module
+# https://rt.cpan.org/Ticket/Display.html?id=100478
+my %mods =
+  map { $file_names{$_} => $_ }
+  grep { $file_names{$_} =~ /\Q$_\E$/ } keys %file_names;
+
 foreach(keys(%mods)) {
   if ($exclude{ $mods{$_} }) {
     delete($mods{$_});
diff --git a/t/fatnode.t b/t/fatnode.t
new file mode 100644 (file)
index 0000000..26878f8
--- /dev/null
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+use strictures 1;
+use Test::More;
+
+plan tests => 1;
+
+require Object::Remote::FatNode;
+my $data =  do {
+    no warnings 'once';
+    $Object::Remote::FatNode::DATA;
+};
+
+ok $data !~ m|MODULELOADER_HOOK|mx,'MODULELOADER_HOOK should not be in the fatpack.';