Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

make test and File::Spec problems

by Dirk80 (Pilgrim)
on Jun 29, 2012 at 20:05 UTC ( #979175=perlquestion: print w/replies, xml ) Need Help??

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


I get warnings when I'm using "make test" with a ".t" file which contains e.g. the following line:



Use of uninitialized value $file in string ne at /usr/lib/perl/5.14/Fi +le/Spec/ line 136. Use of uninitialized value $file in concatenation (.) or string at /us +r/lib/perl/5.14/File/Spec/ line 144.

If I'm executing the ".t" file directly with perl "t/abc.t" or with prove instead of make test then I don't get these warnings.

What can I do? I don't want to have these warnings, when the test cases are executed with "make test".

Thank you


Replies are listed 'Best First'.
Re: make test and File::Spec problems
by dulwar (Monk) on Jun 29, 2012 at 21:38 UTC
    The documentation for File::Spec::catpath specifies:

    Takes volume, directory and file portions and returns an entire path. Under Unix, $volume is ignored, and directory and file are concatenated. A / is inserted if need be. On other OSes, $volume is significant.

        $full_path = File::Spec->catpath( $volume, $directory, $file );

    The call in your script is missing the third parameter $file, so the catpath method is using an undefined value in the concatenation. If you change the line to

        File::Spec->catpath("","/usr/bin", "");

    then you will not get the warnings.

      Thank you. I'm sure that's the reason for the warnings. And I'd like to try it. But I first have to find out how to downgrade the module Test::Harness from 3.25 back to 3.23.


      Downgraded to Test::Harness 3.23 with the following command within the cpan shell:

      install ANDYA/Test-Harness-3.23.tar.gz

      Then I checked that the correct version is installed with:

      perl -MTest::Harness -e 'print "$Test::Harness::VERSION\n"'

      Then I updated the line in the test script. And you are right. The warnings are gone now also when I'm using Test::Harness Version 3.23.

Re: make test and File::Spec problems
by chromatic (Archbishop) on Jun 29, 2012 at 20:43 UTC

      Thank you. I had version 3.23 of Test::Harness and now updated to 3.25. Now it is working without warnings.

      Is the warning now just suppressed from the new Test::Harness module or should I change something in the code to really solve the warning?

        When earlier versions of T::H launched external Perl processes in which to run your tests, they unilaterally added the -w flag. That enables warnings globally throughout the entire Perl process, even if the author didn't develop with warnings enabled.

        Since the release of Perl 5.6.0 in early 2000, the warnings pragma has had lexical scoping, so that individual modules, files, and scopes can enable or disable warnings on their own.

        Something somewhere in File::Spec produces that warning, but no one who's patched that module has felt the need to fix it because it's clearly not an error and it only produces a warning if you ignore lexical warnings.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://979175]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-03-21 08:04 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (59 votes). Check out past polls.