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