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