4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 15 + 12;
7 use_ok 'Module::Build';
8 ensure_blib('Module::Build');
10 my $tmp = MBTest->tmpdir;
14 my $dist = DistGen->new(dir => $tmp);
16 $dist->add_file('t/special_ext.st', <<'---');
18 use Test::More tests => 2;
19 ok(1, 'first test in special_ext');
20 ok(1, 'second test in special_ext');
23 $dist->add_file('t/another_ext.at', <<'---');
25 use Test::More tests => 2;
26 ok(1, 'first test in another_ext');
27 ok(1, 'second test in another_ext');
29 $dist->add_file('t/foo.txt', <<'---');
31 use Test::More tests => 1;
32 ok 0, "don't run this non-test file";
33 die "don't run this non-test file";
38 #########################
40 my $mb = Module::Build->subclass(
42 sub ACTION_testspecial {
43 shift->generic_test(type => 'special');
46 sub ACTION_testanother {
47 shift->generic_test(type => 'another');
51 module_name => $dist->name,
61 my $special_output = uc(stdout_of(
62 sub {$mb->dispatch('testspecial', verbose => 1)}
65 like($special_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
66 'saw expected output from first test');
67 like($special_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
68 'saw expected output from second test');
70 my $another_output = uc(stdout_of(
71 sub {$mb->dispatch('testanother', verbose => 1)}
74 ok($another_output, 'we have some test output');
76 like($another_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m,
77 'saw expected output from first test');
78 like($another_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m,
79 'saw expected output from second test');
82 my $all_output = uc(stdout_of(
83 sub {$mb->dispatch('testall', verbose => 1)}
86 0 and warn "\ntestall said >>>\n$all_output\n<<<\n";
88 like($all_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
89 'expected output from basic.t');
90 like($all_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
91 'expected output from basic.t');
93 like($all_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m);
94 like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m);
96 # we get a third one from basic.t
97 is(scalar(@{[$all_output =~ m/OK 1/mg]}), 3 );
98 is(scalar(@{[$all_output =~ m/OK/mg]}), 8 );
99 is(scalar(@{[$all_output =~ m/ALL TESTS SUCCESSFUL\./mg]}), 1);
105 $dist->add_file('t/foo/special.st', <<'---');
107 use Test::More tests => 2;
108 ok(1, 'first test in special_ext');
109 ok(1, 'second test in special_ext');
111 $dist->add_file('t/foo/basic_foo.t', <<'---');
112 use Test::More tests => 1;
113 use strict; use Simple;
119 my $mb = Module::Build->subclass(
121 sub ACTION_testspecial {
122 shift->generic_test(type => 'special');
125 sub ACTION_testanother {
126 shift->generic_test(type => 'another');
130 recursive_test_files => 1,
131 module_name => $dist->name,
140 my $special_output = uc(stdout_of(
141 sub {$mb->dispatch('testspecial', verbose => 1)}
144 like($special_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
145 'saw expected output from first test');
146 like($special_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
147 'saw expected output from second test');
149 my $another_output = uc(stdout_of(
150 sub {$mb->dispatch('testanother', verbose => 1)}
153 ok($another_output, 'we have some test output');
155 like($another_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m,
156 'saw expected output from first test');
157 like($another_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m,
158 'saw expected output from second test');
161 my $all_output = uc(stdout_of(
162 sub {$mb->dispatch('testall', verbose => 1)}
165 like($all_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m,
166 'expected output from basic.t');
167 like($all_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m,
168 'expected output from basic.t');
170 like($all_output, qr/^OK 1 - FIRST TEST IN ANOTHER_EXT/m);
171 like($all_output, qr/^OK 2 - SECOND TEST IN ANOTHER_EXT/m);
173 # we get a third one from basic.t
174 is(scalar(@{[$all_output =~ m/(OK 1)/mg]}), 5 );
175 is(scalar(@{[$all_output =~ m/(OK)/mg]}), 13 );
180 # vim:ts=4:sw=4:et:sta