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

Greetings O Monks:

I've written a module Chart::Scientific for CPAN, using Test::More to perform the tests. (Everything I'm doing was generated boilerplate out of 'h2xs -AX -n Chart::Scientific'). I'm having some odd behavior with the tests, though.

When I do:

perl Makefile.PL make make test
I get this mess:

% make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_h +arness(0, 'blib/lib', 'blib/arch')" t/*.t t/Chart-Scientific....NOK 2# Failed test (t/Chart-Scientific.t at +line 13) # Tried to use 'Chart::Scientific'. # Error: Can't load '/usr/local/lib/perl/5.8.4/auto/PGPLOT/PGPLOT +.so' for module PGPLOT: /usr/lib/gcc-lib/i486-linux/3.3.5/../../../li +bpgplot.so.5: undefined symbol: png_set_text at /usr/lib/perl/5.8/Dyn +aLoader.pm line 225. # at /usr/local/lib/perl/5.8.4/PDL/Graphics/PGPLOT/Window.pm line 210 +7 # Compilation failed in require at /usr/local/lib/perl/5.8.4/PDL/Graph +ics/PGPLOT/Window.pm line 2107. # BEGIN failed--compilation aborted at /usr/local/lib/perl/5.8.4/PDL/G +raphics/PGPLOT/Window.pm line 2107. # Compilation failed in require at /usr/local/lib/perl/5.8.4/PDL/Graph +ics/PGPLOT.pm line 146. # BEGIN failed--compilation aborted at /usr/local/lib/perl/5.8.4/PDL/G +raphics/PGPLOT.pm line 146. # Compilation failed in require at /home/allen94/bin/Chart-Scientific/ +blib/lib/Chart/Scientific.pm line 13. # BEGIN failed--compilation aborted at /home/allen94/bin/Chart-Scienti +fic/blib/lib/Chart/Scientific.pm line 13. # Compilation failed in require at (eval 36) line 2. uneven data: 45 reference images, 0 test images at t/Chart-Scientific. +t line 24. # Looks like you planned 47 tests but only ran 2. # Looks like your test died just after 2. t/Chart-Scientific....dubious + Test returned status 255 (wstat 65280, 0xff00) DIED. FAILED tests 2-47 Failed 46/47 tests, 2.13% okay Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t/Chart-Scientific.t 255 65280 47 91 193.62% 2-47 Failed 1/1 test scripts, 0.00% okay. 46/47 subtests failed, 2.13% okay +. make: *** [test_dynamic] Error 2

So, okay, something's wrong. But, when I run the test file manually, everything's copacetic:

% perl t/Chart-Scientific.t 1..47 ok 1 - use PDL; ok 2 - use Chart::Scientific; ok 3 - t/reference01.ps matches t/test01.ps ok 4 - t/reference02.ps matches t/test02.ps ok 5 - t/reference03.ps matches t/test03.ps ok 6 - t/reference04.ps matches t/test04.ps ok 7 - t/reference05.ps matches t/test05.ps ok 8 - t/reference06.ps matches t/test06.ps ok 9 - t/reference07.ps matches t/test07.ps ok 10 - t/reference08.ps matches t/test08.ps ok 11 - t/reference09.ps matches t/test09.ps ok 12 - t/reference10.ps matches t/test10.ps ok 13 - t/reference11.ps matches t/test11.ps ok 14 - t/reference12.ps matches t/test12.ps ok 15 - t/reference13.ps matches t/test13.ps ok 16 - t/reference14.ps matches t/test14.ps ok 17 - t/reference15.ps matches t/test15.ps ok 18 - t/reference16.ps matches t/test16.ps ok 19 - t/reference18.ps matches t/test18.ps ok 20 - t/reference19.ps matches t/test19.ps ok 21 - t/reference20.ps matches t/test20.ps ok 22 - t/reference21.ps matches t/test21.ps ok 23 - t/reference22.ps matches t/test22.ps ok 24 - t/reference23.ps matches t/test23.ps ok 25 - t/reference24.ps matches t/test24.ps ok 26 - t/reference25.ps matches t/test25.ps ok 27 - t/reference26.ps matches t/test26.ps ok 28 - t/reference27.ps matches t/test27.ps ok 29 - t/reference29.ps matches t/test29.ps ok 30 - t/reference31.ps matches t/test31.ps ok 31 - t/reference32.ps matches t/test32.ps ok 32 - t/reference33.ps matches t/test33.ps ok 33 - t/reference34.ps matches t/test34.ps ok 34 - t/reference35.ps matches t/test35.ps ok 35 - t/reference36.ps matches t/test36.ps ok 36 - t/reference37.ps matches t/test37.ps ok 37 - t/reference38.ps matches t/test38.ps ok 38 - t/reference39.ps matches t/test39.ps ok 39 - t/reference40.ps matches t/test40.ps ok 40 - t/reference41.ps matches t/test41.ps ok 41 - t/reference42.ps matches t/test42.ps ok 42 - t/reference43.ps matches t/test43.ps ok 43 - t/reference44.ps matches t/test44.ps ok 44 - t/reference45.ps matches t/test45.ps ok 45 - t/reference46.ps matches t/test46.ps ok 46 - t/reference47.ps matches t/test47.ps ok 47 - t/reference48.ps matches t/test48.ps

I am well and truly stumped. Can anyone point me in the right direction to fix my test?

Kester

2004-12-03 Janitored by Arunbear - added readmore tags, as per Monastery guidelines

Replies are listed 'Best First'.
Re: Inner workings of "make test"
by chromatic (Archbishop) on Dec 02, 2004 at 22:45 UTC

    Does which perl produce something different from /usr/bin/perl? I wouldn't think so, but it's the first thing that comes to mind initially.

    If that doesn't help, can you post the setup portion of your test? (In most of my tests, this sets @INC, changes directories sometimes, and loads a couple of modules.)

      My default perl is OK:

      % which perl /usr/bin/perl

      Here is the the setup and main routine of the test:

      use strict; use warnings; use Data::Dumper; use Test::More tests => 47; BEGIN { use_ok ( 'PDL' ); use_ok ( 'Chart::Scientific' ); }; main (); sub main { make_test_images (); my @ref_data = get_reference_data (); my @test_data = get_test_data (); die "uneven data: ", scalar @ref_data, " reference images, ", scalar @test_data, " test images" if scalar @ref_data != scalar @test_data; foreach ( 0 .. scalar @ref_data - 1 ) { is ( $ref_data[$_]{data}, $test_data[$_]{data}, "$ref_data[$_]{name} matches $test_data[$_]{name}" ); unlink $test_data[$_]{name} or warn "can't delete $test_data[$_]{name}"; } }
Re: Inner workings of "make test"
by osunderdog (Deacon) on Dec 03, 2004 at 00:23 UTC

    Perhaps try make distclean and then make.

    You can step in to that particular test using: make testdb TEST_FILE=t/Chart-Scientific.t But it looks more like a rebuild is in order.

    When you run through make, you're picking up the package from 'blib/lib', 'blib/arch'. Kinda like calling perl -Iblib/lib -Iblib/arc t/Chart-Scientific.t The packages are stored in blib for testing and verification. They are only moved to your real perl package directory after you do an install.

    OTOH, when you call perl t/Chart-Scientific.t you are picking the package up from your perl lib path. (whatever that is.) perl -V will tell you.


    "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


    OSUnderdog

      I'm still getting the same errors after doing a make distclean. Hmmm...

      It looks like a a library isn't being seen, but I don't understand why it works from the command line. Does make test have a different library environment than straight perl?

        YES. Here is an example. I created a simple ( h2xs -XA FOO ) package (no XS) and ran make -n testdb TEST_FILE=t/1.t the -n tells make to report what it would do if it were to run (which it doesn't)

        $make -n testdb TEST_FILE=t/2.t /nfs/mu/apps/perl/5.8.4/bin/perl "-MExtUtils::Command" -e mkpath \ blib/lib blib/lib/auto/FOO \ blib/arch/auto/FOO blib/bin \ blib/script blib/man1 \ blib/man3 chmod 755 \ blib/lib blib/lib/auto/FOO \ blib/arch/auto/FOO blib/bin \ blib/script blib/man1 \ blib/man3 touch blibdirs /bin/sh -c true /nfs/mu/apps/perl/5.8.4/bin/perl -MExtUtils::Install -e 'pm_to_blib({@ +ARGV}, '\''blib/lib/auto'\'', '\'''\'')' \ FOO.pm blib/lib/FOO.pm touch pm_to_blib /bin/sh -c true /bin/sh -c true /bin/sh -c true /bin/sh -c true PERL_DL_NONLAZY=1 /nfs/mu/apps/perl/5.8.4/bin/perl -d "-Iblib/lib" "-I +blib/arch" t/2.t

        Notice the last line:

        PERL_DL_NONLAZY=1 /nfs/mu/apps/perl/5.8.4/bin/perl -d "-Iblib/lib" "-Iblib/arch" t/2.t

        This calls perl with blib/lib and blib/arch ahead of everything else in the @INC list of package directories to search. This will ensure that the package(s) you are testing are picked up before whatever else is in @INC.

        For example, heres a test that will report what @INC has:

        # Before `make install' is performed this script should be runnable wi +th # `make test'. After `make install' it should work as `perl 1.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 1; print join("\n", @INC); ok(1);

        Now when I run this using the make:

        $make testdb TEST_FILE=t/2.t PERL_DL_NONLAZY=1 /nfs/mu/apps/perl/5.8.4/bin/perl -d "-Iblib/lib" "-I +blib/arch" t/2.t Reading ~/.perldb options. Loading DB routines from perl5db.pl version 1.25 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. 1..1 main::(t/2.t:10): print join("\n", @INC); DB<1> c blib/lib blib/arch /home/memyselfandi/lib /foo/apps/perl/5.8.4/lib /foo/sdk/perl/5.8.4/sitelib/prod/lib /foo/foofoo/corplib/gcc331/prod/perllib/lib .ok 1 Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB<1> q

        "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


        OSUnderdog