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; |
10b84a45 |
6 | use lib 't/lib'; |
738349a8 |
7 | use MBTest 'no_plan'; |
8 | |
9 | use DistGen qw(undent); |
10 | |
613f422f |
11 | blib_load('Module::Build'); |
12 | blib_load('Module::Build::ConfigData'); |
738349a8 |
13 | |
14 | # XXX DistGen shouldn't be assuming module-ness? |
15 | my $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 | |
35 | my %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 | ); |
41 | my %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; |
60 | rmdir('lib'); |
61 | |
62 | #system('konsole'); |
63 | my $mb = Module::Build->new_from_context; |
64 | ok($mb); |
65 | is($mb->program_name, 'bin/foo'); |
66 | is($mb->license, 'perl'); |
67 | is($mb->dist_name, 'bin-foo'); |
68 | is($mb->dist_version, '0.01'); |
69 | is_deeply($mb->dist_author, |
70 | ['A. U. Thor, a.u.thor@a.galaxy.far.far.away']); |
71 | ok $mb->dispatch('distmeta'); |
72 | |
738349a8 |
73 | SKIP: { |
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; |