4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 14 + 12;
9 my $tmp = File::Spec->catdir($cwd, 't', '_tmp');
13 my $dist = DistGen->new(dir => $tmp);
15 $dist->add_file('t/special_ext.st', <<'---');
17 use Test::More tests => 2;
18 ok(1, 'first test in special_ext');
19 ok(1, 'second test in special_ext');
22 $dist->add_file('t/another_ext.at', <<'---');
24 use Test::More tests => 2;
25 ok(1, 'first test in another_ext');
26 ok(1, 'second test in another_ext');
28 $dist->add_file('t/foo.txt', <<'---');
30 use Test::More tests => 1;
31 ok 0, "don't run this non-test file";
32 die "don't run this non-test file";
37 chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!";
39 #########################
41 use_ok 'Module::Build';
43 my $mb = Module::Build->subclass(
45 sub ACTION_testspecial {
46 shift->generic_test(type => 'special');
49 sub ACTION_testanother {
50 shift->generic_test(type => 'another');
54 module_name => $dist->name,
64 my $special_output = uc(stdout_of(
65 sub {$mb->dispatch('testspecial', verbose => 1)}
68 like($special_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
69 'saw expected output from first test');
70 like($special_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
71 'saw expected output from second test');
73 my $another_output = uc(stdout_of(
74 sub {$mb->dispatch('testanother', verbose => 1)}
77 ok($another_output, 'we have some test output');
79 like($another_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m,
80 'saw expected output from first test');
81 like($another_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m,
82 'saw expected output from second test');
85 my $all_output = uc(stdout_of(
86 sub {$mb->dispatch('testall', verbose => 1)}
89 0 and warn "\ntestall said >>>\n$all_output\n<<<\n";
91 like($all_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
92 'expected output from basic.t');
93 like($all_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
94 'expected output from basic.t');
96 like($all_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m);
97 like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m);
99 # we get a third one from basic.t
100 is(scalar(@{[$all_output =~ m/OK 1/mg]}), 3 );
101 is(scalar(@{[$all_output =~ m/OK/mg]}), 8 );
102 is(scalar(@{[$all_output =~ m/ALL TESTS SUCCESSFUL\./mg]}), 1);
104 chdir($cwd) or die "Can't chdir to '$cwd': $!";
109 $dist->add_file('t/foo/special.st', <<'---');
111 use Test::More tests => 2;
112 ok(1, 'first test in special_ext');
113 ok(1, 'second test in special_ext');
115 $dist->add_file('t/foo/basic_foo.t', <<'---');
116 use Test::More tests => 1;
117 use strict; use Simple;
122 chdir($dist->dirname) or die "Can't chdir to '@{[$dist->dirname]}': $!";
124 my $mb = Module::Build->subclass(
126 sub ACTION_testspecial {
127 shift->generic_test(type => 'special');
130 sub ACTION_testanother {
131 shift->generic_test(type => 'another');
135 recursive_test_files => 1,
136 module_name => $dist->name,
145 my $special_output = uc(stdout_of(
146 sub {$mb->dispatch('testspecial', verbose => 1)}
149 like($special_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
150 'saw expected output from first test');
151 like($special_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
152 'saw expected output from second test');
154 my $another_output = uc(stdout_of(
155 sub {$mb->dispatch('testanother', verbose => 1)}
158 ok($another_output, 'we have some test output');
160 like($another_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m,
161 'saw expected output from first test');
162 like($another_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m,
163 'saw expected output from second test');
166 my $all_output = uc(stdout_of(
167 sub {$mb->dispatch('testall', verbose => 1)}
170 like($all_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
171 'expected output from basic.t');
172 like($all_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
173 'expected output from basic.t');
175 like($all_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m);
176 like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m);
178 # we get a third one from basic.t
179 is(scalar(@{[$all_output =~ m/(OK 1)/mg]}), 5 );
180 is(scalar(@{[$all_output =~ m/(OK)/mg]}), 13 );
182 chdir($cwd) or die "Can't chdir to '$cwd': $!";
186 # vim:ts=4:sw=4:et:sta