Steve Hay <[EMAIL PROTECTED]> writes:

Hi Steve, we meet again ;-)


>Those message obviously come from the "test" target in the sub-directory 
>Makefile's.  I would like to suppress them because they look slightly 
>alarming:  It looks as if I haven't written tests for the Foo and Bar 
>modules, but really I have -- they're in the top-level t/ sub-directory.

Well you could:
  A. Move them down
  B. Provide as basic test in each subdir.
  C. Override test as you have been

>
>Is there a more elegant way to do what I'm trying to achieve?
>

Tk and some other things I have done with multiple sub-dirs
define a MMutil.pm e.g. Tk/MMutil.pm

That looks like:

------------------------------------------------------------
package Tk::MMutil;
@MYEXPORT = qw(pasthru perldepend ... );

sub import
{
 no strict 'refs';
 my $class = shift;
 my @list = (@_) ? @_ : @{"${class}::MYEXPORT"};
 my $name;
 foreach $name (@list)
  {
   *{"MY::$name"} = \&{"$name"};
  }
}
------------------------------------------------------------

Then sub-Makefiles do 
use Tk::MMutil;

The "import" via glob doesn't redefine the sub just puts in 
in the right place.

Note that MakeMaker does extensive surgery to the symbol table 
to that each directory effectivley gets its own "MY::" space
It gives me me feel ill every time I look at it.

However Tk solves the problem you are having by overriding 'test'
not in the subdirs, but in the top level (which is what 
calls tests in subdirs...) thus:

sub MY::test
{
 my ($self,%attrib) = @_;

 my $dir  = delete $self->{'DIR'};
 my @td;
 foreach my $sd (@$dir)
  {
   my @tests = sort glob($self->catfile($sd,'t','*.t'));
   if (@tests)
    {
     warn "Tests in $sd\n";
     push(@td,$sd);
    }
  }
 if (@td)
  {
   $self->{DIR} = [EMAIL PROTECTED];
  }
 my $str  = $self->MM::test(%attrib);
 # Put sub-dirs back
 $self->{'DIR'} = $dir;
 return $str;
}

i.e.:

save subdir list and clear it.
See if there _are_ any tests in subdirs (skip if you know there aren't)
call the normal MM::test with modified subdir list
put subdirs back.


Reply via email to