(my $stub = $_) =~ s/\.pm$//;
my $name = uc join '_', split '/', $stub;
my $data = $files->{$_}; $data =~ s/^/ /mg; $data =~ s/(?<!\n)\z/\n/;
- '$fatpacked{'.perlstring($_).qq!} = <<'${name}';\n!
+ '$fatpacked{'.perlstring($_).qq!} = '#line '.(1+__LINE__).' "'.__FILE__."\\"\\n".<<'${name}';\n!
.qq!${data}${name}\n!;
} sort keys %$files;
Mithaldu - Christian Walde (cpan:MITHALDU) <walde.christian@googlemail.com>
+dolmen - Olivier Mengué (cpan:DOLMEN) <dolmen@cpan.org>
+
Many more people are probably owed thanks for ideas. Yet
another doc nit to fix.
--- /dev/null
+#!perl
+use strict;
+use warnings FATAL => 'all';
+use Test::More tests => 3;
+use File::Temp qw/tempdir/;
+use File::Spec;
+
+BEGIN { use_ok "App::FatPacker", "" }
+
+chdir 't/line';
+
+my $fp = App::FatPacker->new;
+my $temp_fh = File::Temp->new;
+select $temp_fh;
+$fp->script_command_file([ 'line-test.pl' ]);
+select STDOUT;
+close $temp_fh;
+
+# make sure we don't pick up things from our created dir
+chdir File::Spec->tmpdir;
+
+# Packed, now try using it. This should run the tests inside t/line/a.pm
+do $temp_fh;
--- /dev/null
+
+# This file will be included in the packed file generated by t/line.t
+
+# Check that the name is the one of the packed file
+is __FILE__, $main_file, '__FILE__';
+# Check that the line is the one where the module code starts in the packed file
+is __LINE__, 14, '__LINE__';
+
+1;
--- /dev/null
+
+# To run this test manually:
+# perl -I../../lib ../../bin/fatpack file line-test.pl | perl
+
+package OurTest;
+
+use Test::More;
+
+our $main_file = __FILE__;
+note "File: $main_file";
+
+# Run the tests in the packed file
+do 'line/a.pm';
+