Tests

Is it possible to do a perl unit test that uses the RT config file? I
tried this is my test:

#!perl -T

use Test::More tests => 1;

use RT;

BEGIN {
RT::LoadConfig();
use_ok( ‘RTx:FooBar’ );
};

And I get some errors about being unable to use RT_SiteConfig.pm:
t/01-db.t … Couldn’t load RT config file RT_SiteConfig.pm:

Insecure dependency in require while running with -T switch at
/opt/rt4/lib/RT/Config.pm line 904.
BEGIN failed–compilation aborted at t/01-db.t line 11.

Looks like your test exited with 2 before it could output anything.

t/01-db.t … Dubious, test returned 2 (wstat 512, 0x200)

I’ve got RTHOME and PERL5LIB set so that it can find the RT installation
and libs.

http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

In your script add:

use libs /opt/rt4/lib/

To see if for some reason your env vars aren’t seeing the RT path.

It “may” be use lib and not use libs. I’m not at workstation to log in and check.On Mar 28, 2012, at 5:56 PM, Paul Tomblin ptomblin@xcski.com wrote:

Is it possible to do a perl unit test that uses the RT config file? I tried this is my test:

#!perl -T

use Test::More tests => 1;

use RT;

BEGIN {
RT::LoadConfig();
use_ok( ‘RTx:FooBar’ );
};

And I get some errors about being unable to use RT_SiteConfig.pm:
t/01-db.t … Couldn’t load RT config file RT_SiteConfig.pm:

Insecure dependency in require while running with -T switch at /opt/rt4/lib/RT/Config.pm line 904.
BEGIN failed–compilation aborted at t/01-db.t line 11.

Looks like your test exited with 2 before it could output anything.

t/01-db.t … Dubious, test returned 2 (wstat 512, 0x200)

I’ve got RTHOME and PERL5LIB set so that it can find the RT installation and libs.


http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

In your script add:

use libs /opt/rt4/lib/

To see if for some reason your env vars aren’t seeing the RT path.

Turns out it’s ‘use lib qw{/opt/rt4/lib};’, but it didn’t seem to help.
Thanks anyway.

http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin

Insecure dependency in require while running with -T switch at /opt/rt4/lib/RT/Config.pm line 904.

That’s the key line. It looks like a conflict between using taint mode and the Config.pm file. Try the test without taint mode on? It doesn’t really matter for a unit test, and RT is known not to work under taint mode anyway.

Tim

The Wellcome Trust Sanger Institute is operated by Genome Research
Limited, a charity registered in England with number 1021457 and a
company registered in England with number 2742969, whose registered
office is 215 Euston Road, London, NW1 2BE.

Insecure dependency in require while running with -T switch at
/opt/rt4/lib/RT/Config.pm line 904.

That’s the key line. It looks like a conflict between using taint mode
and the Config.pm file. Try the test without taint mode on? It doesn’t
really matter for a unit test, and RT is known not to work under taint mode
anyway.

Ah yes, that cracked it. I’m also going to try switching from Test:More to
RT:Test after I recover from my surgery. Thanks.

http://www.linkedin.com/in/paultomblin
http://careers.stackoverflow.com/ptomblin