syphilis has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
For the demo, I have FOO.pm, Makefile.PL and t/01t.t. Here they are:
C:\temp\temp\FOO>type FOO.pm package FOO; $FOO::VERSION = 0.5; 1; C:\temp\temp\FOO>type Makefile.PL use ExtUtils::MakeMaker; WriteMakefile ( NAME => 'FOO', VERSION_FROM => 'FOO.pm', ); C:\temp\temp\FOO>type t\01t.t #!perl -T use FOO; use Test::More tests => 2; is(${^TAINT}, 1, 'taint test'); is($FOO::VERSION, 0.5, 'version test');
When I build that little distro on Win32, perl-5.12.0, all goes well:
C:\temp\temp\FOO>perl makefile.PL Writing Makefile for FOO C:\temp\temp\FOO>dmake test cp FOO.pm blib\lib\FOO.pm C:\perl512_M\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness +(0, 'blib\lib', 'blib\arch')" t/*.t t/01t.t .. ok All tests successful. Files=1, Tests=2, 1 wallclock secs ( 0.09 usr + 0.03 sys = 0.12 CPU +) Result: PASS
But if I then try to run 'perl -T -Mblib t/01t.t', I get:
C:\temp\temp\FOO>perl -T -Mblib t/01t.t Insecure dependency in require while running with -T switch at t/01t.t + line 2. BEGIN failed--compilation aborted at t/01t.t line 2. C:\temp\temp\FOO>
What do I need to do in order that 'perl -T -Mblib t/01t.t' works as expected ?
Preferably, there will be some simple modification I can make to t/01t.t ... but if that's unrealistic, then I might be open to other approaches. However, if the "other approaches" are too cumbersome, then I probably just won't worry about it at all :-)

Cheers,
Rob

Replies are listed 'Best First'.
Re: Running with -T and -Mblib
by Anonymous Monk on Jan 27, 2011 at 07:42 UTC
    blib puts tainted directories in @INC and doesn't attempt to untaint them , ExtUtils::testlib does untaint them

    You can run individual files with (both of these will peek at the shebang)

    prove -vb t/01t.t nmake test TEST_VERBOSE=1 TEST_FILES=t/01t.t dmake test TEST_VERBOSE=1 "TEST_FILES=t/01t.t t/02t.t"
    or
    perl -MExtUtils::testlib -T t/01t.t
    There is probably an equivalent for Module::Build/Build/Build.bat
      Not sure if that fits in all that well with what I asked for ... but, in terms of what I want, that's pretty good :-)
      Thanks !

      There is probably an equivalent for Module::Build

      Not an issue.

      Cheers,
      Rob
        Not sure if that fits in all that well with what I asked for ...

        Well, you could add BEGIN { @INC = map /^(.+)$/, @INC ;  } or the like, or submit a patch for blib and hope it gets propagated :)