Update Module::Build to 0.3603
[p5sagit/p5-mst-13.2.git] / cpan / Module-Build / t / script_dist.t
CommitLineData
738349a8 1#!/usr/bin/perl -w
2# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
3# vim:ts=8:sw=2:et:sta:sts=2
4
5use strict;
10b84a45 6use lib 't/lib';
738349a8 7use MBTest 'no_plan';
8
9use DistGen qw(undent);
10
613f422f 11blib_load('Module::Build');
12blib_load('Module::Build::ConfigData');
738349a8 13
14# XXX DistGen shouldn't be assuming module-ness?
15my $dist = DistGen->new(dir => MBTest->tmpdir);
16$dist->add_file('bin/foo', undent(<<' ---'));
17 #!/usr/bin/perl
7dc9e1b4 18
738349a8 19 package bin::foo;
20 $VERSION = 0.01;
21
22 =head1 NAME
23
24 foo - does stuff
25
26 =head1 AUTHOR
27
28 A. U. Thor, a.u.thor@a.galaxy.far.far.away
29
30 =cut
31
32 print "hello world\n";
33 ---
34
35my %details = (
36 dist_name => 'bin-foo',
37 dist_version_from => 'bin/foo',
38 dist_author => ['A. U. Thor, a.u.thor@a.galaxy.far.far.away'],
39 dist_version => '0.01',
40);
41my %meta_provides = (
42 'bin-foo' => {
43 file => 'bin/foo',
44 version => '0.01',
45 }
46);
47$dist->change_build_pl({
48 # TODO need to get all of this data out of the program itself
49 ! $ENV{EXTRA_TEST} ? (
50 %details, meta_merge => { provides => \%meta_provides, },
51 ) : (),
52 program_name => 'bin/foo',
53 license => 'perl',
54});
55
56# hmm... the old assumption of what a dist looks like is wrong here
57$dist->remove_file('lib/Simple.pm'); $dist->regen;
58
59$dist->chdir_in;
60rmdir('lib');
61
62#system('konsole');
63my $mb = Module::Build->new_from_context;
64ok($mb);
65is($mb->program_name, 'bin/foo');
66is($mb->license, 'perl');
67is($mb->dist_name, 'bin-foo');
68is($mb->dist_version, '0.01');
69is_deeply($mb->dist_author,
70 ['A. U. Thor, a.u.thor@a.galaxy.far.far.away']);
71ok $mb->dispatch('distmeta');
72
738349a8 73SKIP: {
74 skip( 'YAML_support feature is not enabled', 1 )
75 unless Module::Build::ConfigData->feature('YAML_support');
613f422f 76 require YAML::Tiny;
77 my $yml = YAML::Tiny::LoadFile('META.yml');
738349a8 78 is_deeply($yml->{provides}, \%meta_provides);
79}
cdbde1c3 80$dist->chdir_original if $dist->did_chdir;