Re: [Module-build-general] RFC: Build test test_dirs=(list)
Status: Beta
Brought to you by:
kwilliams
|
From: Ken W. <ke...@ma...> - 2003-08-13 16:40:41
|
On Tuesday, August 12, 2003, at 07:02 PM, Michael G Schwern wrote:
> What might be a lot simpler is semantics like this:
>
> # run only foo.t
> Build test test_files=t/foo.t
>
> # run all .t files in t/
> Build test test_files=t/*.t
>
> so rather than having "test_files" and "matching" as seperate beasts,
> just
> run the test_files arguments through glob().
Okay, here's what I'll do. I like running 'test_files' through glob(),
for several reasons. First, it means the default changes from a bunch
of code that finds the files, to the string "t/*.t". Second, I like
the ease of specifying sets of stuff this way, and I think it scales
well.
I think the semantics should work like this:
* Run through split_like_shell().
* Expand with glob().
* Pass through files unaltered, and expand directories using the likes
of glob("$_/*.t").
This will match people's expectations from the shell a little more
closely, I think.
Here's how I'll apply the first patch. The 'recursive_test_files'
property remains unimplemented and I'm not sure about the name yet.
Steve's 'matching' argument can still be implemented later if we want
regexes.
-Ken
--- lib/Module/Build/Base.pm 12 Aug 2003 15:52:39 -0000 1.165
+++ lib/Module/Build/Base.pm 13 Aug 2003 15:24:25 -0000
@@ -1012,13 +1012,21 @@
my @tests;
if ($self->{args}{test_files}) { # XXX use 'properties'
- @tests = $self->split_like_shell($self->{args}{test_files});
+ @tests = (map { -d $_ ? $self->expand_test_dir($_) : $_ }
+ map glob,
+ $self->split_like_shell($self->{args}{test_files}));
} else {
# Find all possible tests in t/ or test.pl
push @tests, 'test.pl' if -e 'test.pl';
- push @tests, @{$self->rscan_dir('t', qr{\.t$})} if -e 't' and -d _;
+ push @tests, $self->expand_test_dir('t') if -e 't' and -d _;
}
return [sort @tests];
+}
+
+sub expand_test_dir {
+ my ($self, $dir) = @_;
+ return @{$self->rscan_dir($dir, qr{\.t$})} if
$self->{properties}{recursive_test_files};
+ return glob File::Spec->catfile($dir, "*.t");
}
sub ACTION_testdb {
|