Add ExtUtils::Miniperl to the list of core modules for all versions >= 5.00504
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / test_type.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if ($^O eq 'VMS') {
5         print '1..0 # Child test output confuses harness';
6         exit;
7     }
8 }
9
10 use strict;
11 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
12 use MBTest tests => 9;
13
14 use_ok 'Module::Build';
15 ensure_blib('Module::Build');
16
17 my $tmp = MBTest->tmpdir;
18
19 use DistGen;
20
21 my $dist = DistGen->new( dir => $tmp );
22
23
24 $dist->add_file('t/special_ext.st', <<'---' );
25 #!perl 
26 use Test::More tests => 2;
27 ok(1, 'first test in special_ext');
28 ok(1, 'second test in special_ext');
29 ---
30
31 $dist->regen;
32
33 $dist->chdir_in;
34
35 #########################
36
37 # Here we make sure we can define an action that will test a particular type
38 $::x = 0;
39 my $mb = Module::Build->subclass(
40     code => q#
41         sub ACTION_testspecial { 
42             $::x++;
43             shift->generic_test(type => 'special');
44         }
45     #
46 )->new(
47     module_name => $dist->name,
48     test_types  => { special => '.st' }
49 );
50
51 ok $mb;
52
53 $mb->dispatch('testspecial');
54 is($::x, 1, "called once");
55
56
57 $mb->add_to_cleanup('save_out');
58 # Use uc() so we don't confuse the current test output
59 my $verbose_output = uc(stdout_of(
60     sub {$mb->dispatch('testspecial', verbose => 1)}
61 ));
62
63 like($verbose_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m);
64 like($verbose_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m);
65
66 is( $::x, 2, "called again");
67
68 my $output = uc(stdout_of(
69     sub {$mb->dispatch('testspecial', verbose => 0)}
70 ));
71 like($output, qr/\.\. ?OK/);
72
73 is($::x, 3, "called a third time");
74
75 $dist->remove;
76
77 # vim:ts=4:sw=4:et:sta