Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

make test hangs

by Anonymous Monk
on Feb 12, 2015 at 16:05 UTC ( [id://1116516]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Perl Manks and Gurus,

I’m stuck in getting any Perl module tested via the make test procedure generated. Here is the output of make with the verbose option activated:

/tmp/DBI-1.633>make test TEST_VERBOSE=1

PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "- e" "undef *Test::Harness::Switches; test_harness(1, 'blib/lib', 'blib/arch')" t/ *.t
t/00simple_test.t ............... <----- here the make hangs and waits for ever !

when I hit the break key I get:

make: *** test_dynamic Quit

The test script just logs a message and is doing nothing else.

Here is the script 00simple_test.t

#!perl -w use strict; my $LOG; my $LOG_FILE = './test_log'; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(tim +e); my $timestamp = sprintf ("%4d-%02d-%02d %02d:%02d:%02d",$year+1900,$mo +n+1,$mday, $hour,$min,$sec); open ($LOG, '>', $LOG_FILE ) or die "Could not open the file $LOG_FIL +E!\n$!\n"; print $LOG "\n### START ############################################## +###########\n"; print $LOG "### $timestamp\n"; # ### Scripts that will run to check the module! # print "ok 1 - running the test $0\n"; print $LOG "ok 1 - running the test $0\n"; print $LOG "### E N D ################################################ +#########\n#"; 1;

Here is the log that was created:

/tmp/DBI-1.633>cat test_log

### START #########################################################
### 2015-02-12 17:13:21
ok 1 - running the test t/00simple_test.t
### E N D #########################################################

When I run the script it outputs this:

ok 1 - running the test t/00simple_test.t

I don’t know why the make hangs. The script itself runs o.k., writes the log entries and I think it also exits? I have no idea if it exits or if the exit is not recognized by the TEST::HARNESS or if I stucks in the ExtUtil module or what happened during the make test run.
The verbose even shows me any indication so I think the TEST::HARNESS has the problem.
Can anybody of you help me how I can isolate this problems to look a little closer to find the root cause ?

Regards WolliK

Replies are listed 'Best First'.
Re: make test hangs
by choroba (Cardinal) on Feb 12, 2015 at 16:33 UTC
    What's in your Makefile? Why don't you use standard testing tools like Test::More?

    Also, standard TAP would emit

    1..1
    at the end to signal the testing is over.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: make test hangs
by syphilis (Archbishop) on Feb 12, 2015 at 23:01 UTC
    The test script ran fine for me (on Windows) as
    dmake test TEST_VERBOSE=1
    I can't see any reason that it shouldn't do the same on other systems but I didn't actually test.

    One thing that might help isolate the cause is to insert some warnings at various points inside the script and see if any of them are output before the hang starts:
    #!perl -w use strict; warn "\nstrict.pm loaded\n"; my $LOG; my $LOG_FILE = './test_log'; warn "\nvariables declared\n"; .... and so on
    What happens if you don't set verbosity ?
    Do you get the same problem with other modules ?
    What else is in the /tmp/DBI-1.633 folder ?

    Cheers,
    Rob

      Hi Rob,

      like i mentioned when I posted this question any output of the script itself is discharged by the TEST::HARNESS module!.
      So also the warnings!
      Thats is why I output to a log and write some informations to check if the script runs.
      It looks that is runs o.k, but I have no idea if it exits or not. When it does not exit the pove or TEST::HARNESS can not proceed and will hang.
      I need to understand who the control gets back to the module that calls my script when I do either a prove or a make test.
      WolliK

      Hi Rob,
      the situation is the same either with or without the TEST_VERBOSE option is set.
      WolliK

        I put your 00_simple_test.t script into t directory on my Ubuntu and running "prove -v" did not hang. Could you, please, try to put the following into 00_simple_test.t and post the results of prove -v?
        #!/usr/bin/perl -w use strict; use Test::More qw( no_plan ); ok(1);
        Next, if you insist on using "make test" for your testing, could you please post the Makefile as choroba has requested? Thanks!
Re: make test hangs
by hotpelmen (Scribe) on Feb 12, 2015 at 16:46 UTC
    Does that log you are giving here come from make test run or from manual run?

      Hi hotpelmen,
      this outpout was produces by a:
      "make test TEST_VERBOSE=1" on the shell.
      When I try to run it as a perl inliner I got the folloing:

      perl -MExtUtils::Command::MM -MTest::Harness - e undef *Test::Har ness::Switches; test_harness(1, 'blib/lib', 'blib/arch') t/ *.t /bin/-sh: syntax error: `(' unexpected
      But I have no idea how to start it manualy or how to use the correct syntax for the perl interpreter?
      Can you help me on this ?

      The log with "### START ##..." was the outout of the test script: 00simple_test.t that I'v created to see what is going on since the TEST::HARNESS will discharge any output to STDOUT.

      I've found this on the internet:
      "make test TEST_VERBOSE=1 TEST_FILE=<test_script> | tee test.log"
      when I run it as:
      "make test TEST_VERBOSE=1 TEST_FILE=t/00simple_test.t | tee test.log"
      It also hangs and there are no additional informations in the created test.log. Did someone know what additional TEST variables I can use to see what is going on ?


      Regards WolliK

        Shouldn't you be able to run prove -bv? Then you don't have to fiddle with the harness directly. If it runs as it should, then your problem is probably something in the makefile. If it doesn't run as it should, the error messages might be more helpful at least.


        Dave

        perl -MExtUtils::Command::MM -MTest::Harness - e undef *Test::Harness: +:Switches; test_harness1, 'blib/lib', 'blib/arch') t/ *.t /bin/-sh: syntax error: `(' unexpected
        I think the problem there is the space in - e, which should be appearing as -e

        Remove that space and at least one of your problems should go away.
        However, I don't know exactly where to look in order to fix whatever it is that's inserting that space - somewhere in ExtUtils::MakeMaker, I guess.
        What version of EU::MM do you have ?

        Update: On closer inspection it seems that you might be responsible for the insertion of that space - as the space aint there in your first post.

        Cheers,
        Rob
Re: make test hangs
by Khen1950fx (Canon) on Feb 13, 2015 at 20:12 UTC
    Ignore "make test" for right now. Tests will run with perl or prove, so let's use them. I tried not to make it too complex but simple, the way you wrote it. Here's my version that I ran:
    #!/usr/bin/perl BEGIN { $ENV{'HARNESS_ACTIVE'} = 1; $ENV{'HARNESS_VERBOSE'} = 1; } use strict; use warnings; use Test::More tests => 1; my $log_file = './test_log'; my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(time); my $timestamp = sprintf( "%4d-%02d-%02d %02d:%02d:%02d", $year + 1900, $mon + 1, $mday, $hour, $min, $sec ); open( OUT, '>', $log_file ) or die "Could not open OUT! $!\n"; binmode OUT, ":encoding(UTF-8)"; print OUT "### START################################################## +##\n"; print OUT "\t $timestamp \n"; ok 1, "running the test $0..."; print OUT "ok 1 - running the test $0"; close(OUT);
    You'll notice that I used environmental variables. It sure makes things easier. I also used binmode. If I'm going to open a file, then I usually binmode it. Don't forget to close the file or filehandle.

    Here's the result, using perl:

    ###START#################################################### 2015-02-13 11:44:06 ok 1 - running the test /root/Desktop/test_hangs.t.tdy
    Here's the result, using prove
    ###START#################################################### 2015-02-13 11:22:31 ok 1 - running the test /root/Desktop/test_hangs.t
    One last thing: Most of the tests that fail can be unhung by using your keyboard. You can use Esc, or Pause/Break. Give it try. It'll take some experimentation and some time. Be patient:). I usually use Num/Lock--Pause/Break--back arrow.

      Hi Khen1950fx,
      it is not the script, ist is also not the prove scriptin /usr/bin, is is the APP:PROOVE witch calls some TAP functions that will not give the control back to my shell.
      I've put some additional logging into the /usr/bin/prove script to see what happened. It:
      - creates the $app
      - processses the $app
      - executes by running the app ($app->run)
      - exits with the either 0 or 1 depending on the previous return value

      The test script is fired up, runs and logs after the entries done by the prove run.

      But the shell where I started the prove command just hangs and waits for ever even if the test script has finished successfull.
      wollik

        Have you tried to test with prove -v against just one little standard test script
        #!/usr/bin/perl -w use strict; use Test::More qw( no_plan ); ok(1);
        as described above to be sure that the test indeed finishes. Please do so and post the results.

        Hi Khen1950fx,
        What do you mean by using different break keys? I fond lots of ways to break out of the opertation and get my shell back, but all these results in quit messages, so the prove or make test routines will not proceed because of the break or quit return value.
        wollik

Re: make test hangs
by hotpelmen (Scribe) on Mar 05, 2015 at 20:15 UTC
    It appears that something's fundamentally wrong with your Test suite installation if trivial and standard test hangs. If you goal is to fix it, have you tried to re-install Test:: modules?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1116516]
Front-paged by tye
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found