Author: Nicholas Bamber <nicholas@periapt.co.uk>
Subject: need to provide path to libraries of distribution
Imagine you have a distrubution consisting of a script and at least
one module. You want to test that the script compiles using this
module. However older versions of your module are already installed.
It is important that we pull in the current version of the modules
not the already released versions. The upstream code does not
take care of this at all. This patch also provides a test.
Bug:
http://rt.cpan.org/Ticket/Display.html?id=72557
Bug-Debian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649332
Last-Update: 2012-02-18
--- /dev/null
+++ b/t/scripts/lib.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+
+BEGIN {
+ require strict;
+ require warnings;
+ require Test::Builder;
+ require File::Spec;
+ require UNIVERSAL::require;
+ @INC = grep { $_ eq 'blib/lib' } @INC;
+}
+use Test::Compile;
+
+sleep 1;
--- /dev/null
+++ b/t/11.lib.t
@@ -0,0 +1,7 @@
+#!perl -w
+use strict;
+use warnings;
+use Test::More tests => 1;
+use Test::Compile;
+pl_file_ok('t/scripts/lib.pl', 'lib.pl compiles');
+
--- a/lib/Test/Compile.pm
+++ b/lib/Test/Compile.pm
@@ -139,6 +139,7 @@
} else {
my @perl5lib = split(':', ($ENV{PERL5LIB}||""));
my $taint = _is_in_taint_mode($file);
+ unshift @perl5lib, 'blib/lib';
system($^X, (map { "-I$_" } @perl5lib), "-c$taint", $file);
return ($? ? 0 : 1);
}
--- a/t/10-find-files.t
+++ b/t/10-find-files.t
@@ -13,10 +13,11 @@
my @files = sort (all_pl_files('t/scripts'));
# THEN
- is(scalar @files,3,"Found correct number of scripts");
+ is(scalar @files,4,"Found correct number of scripts");
like($files[0],qr/failure.pl/,"Found the failure script");
- like($files[1],qr/success.pl/,"Found the success script");
- like($files[2],qr/taint.pl/,"Found the tainted script");
+ like($files[1],qr/lib.pl/,"Found the lib script");
+ like($files[2],qr/success.pl/,"Found the success script");
+ like($files[3],qr/taint.pl/,"Found the tainted script");
}
sub test_all_pm_files {