Upgrade to Module-Build-0.30
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / test_type.t
CommitLineData
7253302f 1#!/usr/bin/perl -w
2
9548cd0f 3BEGIN {
4 if ($^O eq 'VMS') {
5 print '1..0 # Child test output confuses harness';
6 exit;
7 }
8}
9
7253302f 10use strict;
11use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
738349a8 12use MBTest tests => 9;
13
14use_ok 'Module::Build';
15ensure_blib('Module::Build');
7253302f 16
7a827510 17my $tmp = MBTest->tmpdir;
7253302f 18
19use DistGen;
20
21my $dist = DistGen->new( dir => $tmp );
22
23
24$dist->add_file('t/special_ext.st', <<'---' );
25#!perl
26use Test::More tests => 2;
27ok(1, 'first test in special_ext');
28ok(1, 'second test in special_ext');
29---
30
31$dist->regen;
32
738349a8 33$dist->chdir_in;
7253302f 34
35#########################
36
7253302f 37# Here we make sure we can define an action that will test a particular type
38$::x = 0;
39my $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
51ok $mb;
52
53$mb->dispatch('testspecial');
54is($::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
59my $verbose_output = uc(stdout_of(
60 sub {$mb->dispatch('testspecial', verbose => 1)}
61));
62
63like($verbose_output, qr/^OK 1 - FIRST TEST IN SPECIAL_EXT/m);
64like($verbose_output, qr/^OK 2 - SECOND TEST IN SPECIAL_EXT/m);
65
66is( $::x, 2, "called again");
67
68my $output = uc(stdout_of(
69 sub {$mb->dispatch('testspecial', verbose => 0)}
70));
738349a8 71like($output, qr/\.\. ?OK/);
7253302f 72
73is($::x, 3, "called a third time");
74
7253302f 75$dist->remove;
76
77# vim:ts=4:sw=4:et:sta