You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Tracy12 <j_...@yahoo.com> on 2007/01/15 09:51:07 UTC

Test fails/Functionality works

Hi,

I am in the process of changing a perl module written to a Perl
Authentication handler.

Well when I try to deploy the module it failed in the  ' make test' stage
all the other steps went ok.
But the functionality works as expected.


When we execute make test it gives the following error

Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/00.load.t    1   256     1    1 100.00%  1
2 tests skipped.
Failed 1/3 test scripts, 66.67% okay. 1/1 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 255


I found out that the reason for failure is the following line

use Apache2::compat;

but when I remove this entry the make test gives no errors but functionality
fails and in the log it says that
 Can't locate object method "user" via package "Apache2::Connection" at
/usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 512.\n

which is basically   $r->connection->user($user);
line in the source.



Also in the in the 't' folder the source of the 00.load.t is as follows

use Test::More tests => 1;

BEGIN {
use_ok( 'AuthCAS' );
}

diag( "Testing AuthCAS $AuthCAS::VERSION" );


Let us know how to get around with this,








-- 
View this message in context: http://www.nabble.com/Test-fails-Functionality-works-tf3013373.html#a8368295
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Test fails/Functionality works

Posted by Perrin Harkins <pe...@elem.com>.
Tracy12 wrote:
> Error I am getting while executing make test is 
> 
>         all skipped: Test::Pod 1.14 required for testing POD
> Failed Test Stat Wstat Total Fail  Failed  List of Failed
> -------------------------------------------------------------------------------
> t/00.load.t    1   256     1    1 100.00%  1
> 2 tests skipped.
> Failed 1/3 test scripts, 66.67% okay. 1/1 subtests failed, 0.00% okay.
> make: *** [test_dynamic] Error 255

This is not the actual error.  Perl's test harness hides the output of 
STDERR.  You need to run the failing test file individually in order to 
see the real error.

> the 00.load.t looks as follows
> 
> use Test::More tests => 1;
> 
> BEGIN {
> use_ok( 'AuthCAS' );
> }

That test won't work.  Your module uses some of the Apache2:: modules 
and they can't be loaded from a command-line script.  If you want to 
make a test that works, you should look at the Apache::Test framework. 
There are examples in the mod_perl distribution and lots of good 
documentation.

> In order to get everything working I had to comment use strict as well.

Don't do that.  Fix the problems.

> Otherwise it gives me the following.
> This is inside a new added function(hence I used Apache2::Const::OK) in side
> the old code base.
> 
> failed to resolve handler `AuthCAS->authen_handler': Bareword
> "Apache2::Const::OK" not allowed while "strict subs" in use at
> /usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 530.\nCompilation failed in
> require at (eval 2) line 3.\n

It's telling you that you need to load Apache2::Const::OK.  I think that 
loading Apache2::compat will do this for you.

- Perrin

Re: Test fails/Functionality works

Posted by Tracy12 <j_...@yahoo.com>.
Everything working fine with the following entry
Apache2::compat as I stated. 

but eventhough it works ' make test ' gave me a error but still I went ahead
and did make install.

When I comment(to get make test with no errors) the above line 'make test'
gives no errors but that is of no use as functionality does not work.



Error I am getting while executing make test is 

        all skipped: Test::Pod 1.14 required for testing POD
Failed Test Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/00.load.t    1   256     1    1 100.00%  1
2 tests skipped.
Failed 1/3 test scripts, 66.67% okay. 1/1 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 255


the 00.load.t looks as follows

use Test::More tests => 1;

BEGIN {
use_ok( 'AuthCAS' );
}

diag( "Testing AuthCAS $AuthCAS::VERSION" );

In order to get everything working I had to comment use strict as well.
Otherwise it gives me the following.
This is inside a new added function(hence I used Apache2::Const::OK) in side
the old code base.

failed to resolve handler `AuthCAS->authen_handler': Bareword
"Apache2::Const::OK" not allowed while "strict subs" in use at
/usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 530.\nCompilation failed in
require at (eval 2) line 3.\n





Perrin Harkins wrote:
> 
> On Mon, 2007-01-15 at 15:07 -0800, Tracy12 wrote:
>> I am modifying (adding new functions) to already written perl module,
>> 
>> So this is not a complete new development. I am using mod_perl 2.0
>> /Apache
>> 2.2 on Fedora, Looks like code is not written for this but for a older
>> mod_perl version less than 2.0
> 
> I would guess it was written for mod_perl 1.24 or earlier, since that
> connection->user() method was deprecated all the way back then.
> 
>> but  if I change it to $r->user($user) instead of
>> $r->connection->user($user) this looks ok but  it gives further errors
>> on  Can't locate object method "header_out" via package
>> "Apache2::RequestRec" in the line  $r->header_out->set(Location =>
>> $url_new); Is this needs to be changed as well.?
> 
> Yes.  Lots of things will need to be changed.  You're using the mod_perl
> 1 API on mod_perl 2.  You can try using the Apache2::compat module to
> get it running if you don't want to bother rewriting it for mod_perl 2.
> 
> This is all documented here:
> http://perl.apache.org/docs/2.0/user/porting/porting.html
> http://perl.apache.org/docs/2.0/user/porting/compat.html
> 
> Please check these for information on any further errors you receive
> while porting before asking the list.
> 
>> This all happens when I comment the line use Apache2::compat;
> 
> You never explained why you removed that.  It sounds like you should
> keep it, if you just want to port some old code in a hurry.
> 
> - Perrin
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Test-fails-Functionality-works-tf3013373.html#a8382424
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Test fails/Functionality works

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2007-01-15 at 15:07 -0800, Tracy12 wrote:
> I am modifying (adding new functions) to already written perl module,
> 
> So this is not a complete new development. I am using mod_perl 2.0 /Apache
> 2.2 on Fedora, Looks like code is not written for this but for a older
> mod_perl version less than 2.0

I would guess it was written for mod_perl 1.24 or earlier, since that
connection->user() method was deprecated all the way back then.

> but  if I change it to $r->user($user) instead of
> $r->connection->user($user) this looks ok but  it gives further errors
> on  Can't locate object method "header_out" via package
> "Apache2::RequestRec" in the line  $r->header_out->set(Location =>
> $url_new); Is this needs to be changed as well.?

Yes.  Lots of things will need to be changed.  You're using the mod_perl
1 API on mod_perl 2.  You can try using the Apache2::compat module to
get it running if you don't want to bother rewriting it for mod_perl 2.

This is all documented here:
http://perl.apache.org/docs/2.0/user/porting/porting.html
http://perl.apache.org/docs/2.0/user/porting/compat.html

Please check these for information on any further errors you receive
while porting before asking the list.

> This all happens when I comment the line use Apache2::compat;

You never explained why you removed that.  It sounds like you should
keep it, if you just want to port some old code in a hurry.

- Perrin


Re: Test fails/Functionality works

Posted by Tracy12 <j_...@yahoo.com>.
I am modifying (adding new functions) to already written perl module,

So this is not a complete new development. I am using mod_perl 2.0 /Apache
2.2 on Fedora, Looks like code is not written for this but for a older
mod_perl version less than 2.0

Error I got was
Can't locate object method "user" via package "Apache2::Connection

but  if I change it to $r->user($user) instead of
$r->connection->user($user) this looks ok but  it gives further errors
on  Can't locate object method "header_out" via package
"Apache2::RequestRec" in the line  $r->header_out->set(Location =>
$url_new); Is this needs to be changed as well.?


This all happens when I comment the line use Apache2::compat;

Good thing is make test gives zero errors.


How can I preserve existing written old code also make sure make test gives
zero errors. How can I find the corresponing mappings for old vs new perl
versions.

Even though the functionality works in my case make test fails because of
the above line Apache2::compat;


Thanks






Perrin Harkins wrote:
> 
> On Mon, 2007-01-15 at 00:51 -0800, Tracy12 wrote:
>> I found out that the reason for failure is the following line
>> 
>> use Apache2::compat;
> 
> You didn't tell us what the error message is when you have that line in.
> Regardless, you shouldn't use Apache2::compat for new development.  It's
> meant for porting old code.
> 
>> but when I remove this entry the make test gives no errors but
>> functionality
>> fails and in the log it says that
>>  Can't locate object method "user" via package "Apache2::Connection" at
>> /usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 512.\n
>> 
>> which is basically   $r->connection->user($user);
>> line in the source.
> 
> You should be using $r->user($user) there.
> 
> - Perrin
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Test-fails-Functionality-works-tf3013373.html#a8381305
Sent from the mod_perl - General mailing list archive at Nabble.com.


Re: Test fails/Functionality works

Posted by Perrin Harkins <pe...@elem.com>.
On Mon, 2007-01-15 at 00:51 -0800, Tracy12 wrote:
> I found out that the reason for failure is the following line
> 
> use Apache2::compat;

You didn't tell us what the error message is when you have that line in.
Regardless, you shouldn't use Apache2::compat for new development.  It's
meant for porting old code.

> but when I remove this entry the make test gives no errors but functionality
> fails and in the log it says that
>  Can't locate object method "user" via package "Apache2::Connection" at
> /usr/lib/perl5/site_perl/5.8.8/AuthCAS.pm line 512.\n
> 
> which is basically   $r->connection->user($user);
> line in the source.

You should be using $r->user($user) there.

- Perrin