Calling subroutine

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pagarwalla1234
    New Member
    • Mar 2008
    • 5

    Calling subroutine

    Hi,

    Below is the part of code from a test FW I am working on :
    [CODE=perl]sub run {

    [I]my $self = shift;
    $self->SUPER::LogDirG en( ); # priti
    my $config = new Config::Simple( $self->{ config } );
    my %config_hash = $config->vars( );
    print ("1............ ......");
    foreach ( @{ $self->{ queue } } ) {
    print ("2............ ......");
    Class::Autouse->load( $_ );
    my $test_object = $_->new( \%config_hash );
    my $test_name = $_;
    print ("test object is : $test_object... ...\n");
    print ("test name is : $test_name..... .............\n ");
    #$self->SUPER::LogFile Gen($test_name) ; #priti
    foreach ( grep( m/^test/, @{ Class::Inspecto r->methods( $_ ) } ) ) {
    print ("4............ ......");
    foreach ( 'setUp', $_, 'tearDown' ) {
    print ("5............ ......");
    eval { $test_object->$_( ) };
    my $tc = $_;
    print ("at the end...$tc \n");
    }
    }
    }
    }[/CODE]
    This part of code works fine. I try to call "$self->SUPER::LogFile Gen($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 :

    Code:
    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
            Automat::Framework::TestSuiteRunner::run('Automat::Framework::TestSuiteR
    unner=HASH(0x226054)') called at run.pl line 36
    # Looks like you failed 3 tests of 25.
    # Looks like your test died just after 25.
    Below is the sample LogFileGen subroutine:
    [CODE=perl]sub LogFileGen {
    my $test_object = $_[1];
    print "content-type: $ext/html \n\n";
    $FH = "filehandle ";
    chdir ("Log$now_strin g");
    my $cur = getcwd;
    open (OUTPUT, ">$test_object. txt");
    my $Test = Test::Builder->new;
    $Test->output("$test_ object.txt");
    return();
    }[/CODE]

    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
    Last edited by eWish; Mar 10 '08, 08:31 PM. Reason: Please use [CODE][/CODE] tags
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Looks like you need to start by installing the TestCalenders.p m module.

    Comment

    • pagarwalla1234
      New Member
      • Mar 2008
      • 5

      #3
      It is already. The error is coming only when I call the LogFileGel subrouting from this subroutine.

      Comment

      • numberwhun
        Recognized Expert Moderator Specialist
        • May 2007
        • 3467

        #4
        Originally posted by pagarwalla1234
        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.p m 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.p m 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

        Comment

        • pagarwalla1234
          New Member
          • Mar 2008
          • 5

          #5
          Thanks . I will surely keep that in mind.
          If you see the code, there is :
          [CODE=perl]Class::Autouse->load( $_ ); # @ line 10. whick loads all the modules.[/CODE]

          I am not getting the error when I run the code as it is. But when I insert

          [CODE=perl]$self->SUPER::LogFile Gen($test_name) ; #priti - I see the error.[/CODE]
          Hope my question is clear now.

          Thanks.
          Last edited by eWish; Mar 10 '08, 09:09 PM. Reason: Fixed Ccde tags

          Comment

          • pagarwalla1234
            New Member
            • Mar 2008
            • 5

            #6
            Also, let me know how can I make sure that perl is able to find the module.

            Thanks,

            Comment

            • eWish
              Recognized Expert Contributor
              • Jul 2007
              • 973

              #7
              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.

              [CODE=perl]use lib '/path/to/TestCalenders';[/CODE]

              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

              Comment

              • pagarwalla1234
                New Member
                • Mar 2008
                • 5

                #8
                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::LogFile Gen($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

                Comment

                Working...