By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,852 Members | 1,426 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,852 IT Pros & Developers. It's quick & easy.

Calling subroutine

P: 5
Hi,

Below is the part of code from a test FW I am working on :
Expand|Select|Wrap|Line Numbers
  1. sub run {
  2.  
  3.     [i]my $self = shift;
  4.     $self->SUPER::LogDirGen( );    #    priti
  5.     my $config = new Config::Simple( $self->{ config } );
  6.     my %config_hash = $config->vars( );
  7.     print ("1..................");
  8.     foreach ( @{ $self->{ queue } } ) {
  9.     print ("2..................");
  10.         Class::Autouse->load( $_ );
  11.         my $test_object = $_->new( \%config_hash );
  12.         my $test_name = $_;
  13.         print ("test object is : $test_object......\n");
  14.         print ("test name is : $test_name..................\n");
  15.         #$self->SUPER::LogFileGen($test_name);    #priti
  16.         foreach ( grep( m/^test/, @{ Class::Inspector->methods( $_ ) } ) ) {
  17.         print ("4..................");
  18.             foreach ( 'setUp', $_, 'tearDown' ) {
  19.                 print ("5..................");
  20.                 eval { $test_object->$_( ) };
  21.                 my $tc = $_;
  22.                 print ("at the end...$tc \n"); 
  23.             }
  24.         }
  25.     }    
  26. }
This part of code works fine. I try to call "$self->SUPER::LogFileGen($test_name); " commented out in the above code which is a function to redirect my standard outputs to a file. I get the below error :

Expand|Select|Wrap|Line Numbers
  1. Can't locate TestCalenders.pm in @INC (@INC contains: C:/usr/
  2. site/lib, C:/usr/lib, .) at C:/usr/site/lib/Automat/Framework/TestSuiteRunner.pm
  3.  line 49
  4.         Automat::Framework::TestSuiteRunner::run('Automat::Framework::TestSuiteR
  5. unner=HASH(0x226054)') called at run.pl line 36
  6. # Looks like you failed 3 tests of 25.
  7. # Looks like your test died just after 25.
Below is the sample LogFileGen subroutine:
Expand|Select|Wrap|Line Numbers
  1. sub LogFileGen {
  2. my $test_object = $_[1];
  3. print "content-type: $ext/html \n\n"; 
  4. $FH = "filehandle";
  5. chdir ("Log$now_string"); 
  6. my $cur = getcwd;
  7. open (OUTPUT, ">$test_object.txt");
  8. my $Test = Test::Builder->new;
  9. $Test->output("$test_object.txt");
  10. return();
  11. }
Can anybody help to solve the issue. And also if someone please explain me why the error is coming when i cann the LogFileGen subroutine.

Thanks,
Priti
Mar 10 '08 #1
Share this Question
Share on Google+
7 Replies


KevinADC
Expert 2.5K+
P: 4,059
Looks like you need to start by installing the TestCalenders.pm module.
Mar 10 '08 #2

P: 5
It is already. The error is coming only when I call the LogFileGel subrouting from this subroutine.
Mar 10 '08 #3

numberwhun
Expert Mod 2.5K+
P: 3,503
It is already. The error is coming only when I call the LogFileGel subrouting from this subroutine.
I have to agree with Kevin. Considering this error:

Can't locate TestCalenders.pm in @INC (@INC contains: C:/usr/
site/lib, C:/usr/lib, .) at C:/usr/site/lib/Automat/Framework/TestSuiteRunner.pm
line 49

which you so kindly posted, the module TestCalenders.pm is not found. If this is something that you installed, then you need to ensure that Perl can find it, otherwise, its useless. That is why you are getting this error.

Also, Please put code tags around any code you post in the forums. I have fixed it for you this time, but next time things get uglier. ;-)

Regards,

Moderator
Mar 10 '08 #4

P: 5
Thanks . I will surely keep that in mind.
If you see the code, there is :
Expand|Select|Wrap|Line Numbers
  1. Class::Autouse->load( $_ ); # @ line 10. whick loads all the modules.
I am not getting the error when I run the code as it is. But when I insert

Expand|Select|Wrap|Line Numbers
  1. $self->SUPER::LogFileGen($test_name);  #priti  - I see the error.
Hope my question is clear now.

Thanks.
Mar 10 '08 #5

P: 5
Also, let me know how can I make sure that perl is able to find the module.

Thanks,
Mar 10 '08 #6

eWish
Expert 100+
P: 971
TestCalenders does not appear to be a module from CPAN. Unless you installed it in the directory that perl looks for modules, you will need to use the lib pragma before perl will see the module.

Expand|Select|Wrap|Line Numbers
  1. use lib '/path/to/TestCalenders';
Edit:
Below is an example of how to use the code tags:
[CODE]The tags surrond the code that is posted which preserves the format and spacing.[/CODE]

Thank you for trying.

--Kevin
Mar 10 '08 #7

P: 5
I have included the lib pragma and the code run good now. Thanks a lot for the help.

You are right, TestCalender is not a CPAN module. Still I have a doubt (if you dont mind me asking it again).

Why Perl is not able to look for the module ONLY WHEN the "self->SUPER::LogFileGen($test_name);" line in included in the code BUT able to look for the module when I comment this out.

Sorry If I am being repeatative.

Thanks Again.

Priti
Mar 10 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.