Author: ericwilhelm
Date: Sun Feb 18 17:31:31 2007
New Revision: 9129

Modified:
   Module-Build/trunk/lib/Module/Build/Base.pm
   Module-Build/trunk/t/test_types.t

Log:
lib/Module/Build/Base.pm - don't interpolate '.' in find_test_files regexp
t/test_types.t           - verify types with recursive_test_files set (and a 
.txt just to stir things up a bit)


Modified: Module-Build/trunk/lib/Module/Build/Base.pm
==============================================================================
--- Module-Build/trunk/lib/Module/Build/Base.pm (original)
+++ Module-Build/trunk/lib/Module/Build/Base.pm Sun Feb 18 17:31:31 2007
@@ -2124,7 +2124,7 @@
   my ($self, $dir) = @_;
   my $exts = $self->{properties}{test_file_exts} || ['.t'];
 
-  return sort map { @{$self->rscan_dir($dir, qr{^[^.].*$_$})} } @$exts
+  return sort map { @{$self->rscan_dir($dir, qr{^[^.].*\Q$_\E$})} } @$exts
     if $self->recursive_test_files;
 
   return sort map { glob File::Spec->catfile($dir, "*$_") } @$exts;

Modified: Module-Build/trunk/t/test_types.t
==============================================================================
--- Module-Build/trunk/t/test_types.t   (original)
+++ Module-Build/trunk/t/test_types.t   Sun Feb 18 17:31:31 2007
@@ -2,7 +2,7 @@
 
 use strict;
 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
-use MBTest tests => 13;
+use MBTest tests => 13 + 12;
 
 use Cwd ();
 my $cwd = Cwd::cwd();
@@ -25,6 +25,12 @@
 ok(1, 'first test in another_ext');
 ok(1, 'second test in another_ext');
 ---
+$dist->add_file('t/foo.txt', <<'---');
+#!perl 
+use Test::More tests => 1;
+ok 0, "don't run this non-test file";
+die "don't run this non-test file";
+---
 
 $dist->regen;
 
@@ -95,4 +101,83 @@
 chdir($cwd) or die "Can't chdir to '$cwd': $!";
 $dist->remove;
 
+{ # once-again
+
+$dist->add_file('t/foo/special.st', <<'---');
+#!perl 
+use Test::More tests => 2;
+ok(1, 'first test in special_ext');
+ok(1, 'second test in special_ext');
+---
+$dist->add_file('t/foo/basic_foo.t', <<'---');
+use Test::More tests => 1;
+use strict; use Simple;
+ok 1;
+---
+$dist->regen;
+
+chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!";
+
+my $mb = Module::Build->subclass(
+   code => q#
+        sub ACTION_testspecial { 
+            shift->generic_test(type => 'special');
+        }
+
+        sub ACTION_testanother { 
+            shift->generic_test(type => 'another');
+        }
+  #
+  )->new(
+      recursive_test_files => 1,
+      module_name => $dist->name,
+      test_types  => {
+          special => '.st',
+          another => '.at',
+      },
+  );
+
+ok $mb;
+
+my $special_output = uc(stdout_of(
+    sub {$mb->dispatch('testspecial', verbose => 1)}
+));
+
+like($special_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
+    'saw expected output from first test');
+like($special_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
+    'saw expected output from second test');
+
+my $another_output = uc(stdout_of(
+    sub {$mb->dispatch('testanother', verbose => 1)}
+));
+
+ok($another_output, 'we have some test output');
+
+like($another_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m,
+    'saw expected output from first test');
+like($another_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m,
+    'saw expected output from second test');
+
+
+my $all_output = uc(stdout_of(
+    sub {$mb->dispatch('testall', verbose => 1)}
+));
+
+like($all_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
+    'expected output from basic.t');
+like($all_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
+    'expected output from basic.t');
+
+like($all_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m);
+like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m);
+
+# we get a third one from basic.t
+is(scalar(@{[$all_output =~ m/(OK 1)/mg]}), 5 );
+is(scalar(@{[$all_output =~ m/(OK)/mg]}),   13 );
+
+chdir($cwd) or die "Can't chdir to '$cwd': $!";
+$dist->remove;
+} # end once-again
+
 # vim:ts=4:sw=4:et:sta

Reply via email to