James E Keenan wrote:
Randy W. Sims wrote:

The test file below is pared down from Module::Build. The warning from C<require> comes up in several tests, not always causing test failures. The same warning appears if you run MakeMaker as shown in the Devel::Cover docs--it's not specific to Module::Build.


[EMAIL PROTECTED]:~/projects$ module-starter --eumm --mb --module Foo Created starter directories and files

[EMAIL PROTECTED]:~/projects$ cd Foo

[EMAIL PROTECTED]:~/projects/Foo$ rm MANIFEST t/*

[EMAIL PROTECTED]:~/projects/Foo$ cat > t/basic.t
use Test::More tests => 1;
use File::Spec;
require File::Spec->catfile('t', 'common.pl');
ok(1);


Maybe I'm just obtuse tonight, but let me ask anyway: You're creating a module from scratch and the sole test file, t/basic.t, reads as follows:


  use Test::More tests => 1;
  use File::Spec;
  require File::Spec->catfile('t', 'common.pl');
  ok(1);

I don't grok the use of 'require' in line 3 there. As I read the File::Spec docs, 'catfile' is used to return a string containing a path. Is it your intention to immediately 'require' that file? If so, how do you know it exists if you've just started from scratch?

Or is there something obvious I'm not grasping?

This is just a pared down example. In this example common.pl simply contains:


1;

The require line should be equivelant to:

require 't/common.pl';

I suppose the tests in M::B are trying to be as safe as possible, so they use the more cross-platform

require File::Spec->('t', 'common.pl');

to construct the path to a library that contains common code used amoung the various t/*.t tests.

Randy.



Reply via email to