Skip to content

Commit

Permalink
add (failing) tests that demonstrate MYMETA failings
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.perl.org/modules/Module-Build/trunk@13598 50811bd7-b8ce-0310-adc1-d9db26280581
  • Loading branch information
xdg committed Nov 24, 2009
1 parent 65c39d9 commit 541c530
Showing 1 changed file with 73 additions and 3 deletions.
76 changes: 73 additions & 3 deletions t/mymeta.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,98 @@
use strict;
use lib 't/lib';
use MBTest;
plan tests => 7;
plan tests => 23;

blib_load('Module::Build');
blib_load('Module::Build::YAML');

my $tmp = MBTest->tmpdir;

use DistGen;
my $dist = DistGen->new( dir => $tmp );
$dist->change_file('Build.PL', <<"---");
use strict;
use Module::Build;
my \$builder = Module::Build->new(
module_name => '$dist->{name}',
license => 'perl',
requires => {
'File::Spec' => ( \$ENV{BUMP_PREREQ} ? 0.86 : 0 ),
},
);
\$builder->create_build_script();
---
$dist->regen;
$dist->chdir_in;

#########################

# Test MYMETA generation
{
ok( ! -e "META.yml", "META.yml doesn't exist before Build.PL runs" );
ok( ! -e "MYMETA.yml", "MYMETA.yml doesn't exist before Build.PL runs" );
my $output;
$output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
"Saw MYMETA.yml creation message"
"Ran Build.PL and saw MYMETA.yml creation message"
);
ok( -e "MYMETA.yml", "MYMETA.yml exists" );
}

#########################

# Test interactions between META/MYMETA
{
my $output = stdout_of sub { $dist->run_build('distmeta') };
like($output, qr/Creating META.yml/,
"Ran Build distmeta to create META.yml");
my $meta = Module::Build::YAML->read('META.yml');
my $mymeta = Module::Build::YAML->read('MYMETA.yml');
is_deeply( $meta, $mymeta, "Generated MYMETA matches generated META" );
$output = stdout_stderr_of sub { $dist->run_build('realclean') };
like( $output, qr/Cleaning up/, "Ran realclean");
ok( ! -e 'Build', "Build file removed" );
ok( ! -e 'MYMETA.yml', "MYMETA file removed" );

# test that dynamic prereq is picked up
local $ENV{BUMP_PREREQ} = 1;
$output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
"Ran Build.PL with dynamic config"
);
ok( -e "MYMETA.yml", "MYMETA.yml exists" );
$mymeta = Module::Build::YAML->read('MYMETA.yml');
isnt( $meta->[0]{requires}{'File::Spec'},
$mymeta->[0]{requires}{'File::Spec'},
"MYMETA requires differs from META"
);
$output = stdout_stderr_of sub { $dist->run_build('realclean') };
like( $output, qr/Cleaning up/, "Ran realclean");
ok( ! -e 'Build', "Build file removed" );
ok( ! -e 'MYMETA.yml', "MYMETA file removed" );

# manually change META and check that changes are preserved
$meta->[0]{author} = ['John Gault'];
ok( $meta->write('META.yml'), "Wrote manually modified META.yml" );

$output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
"Ran Build.PL"
);
my $mymeta2 = Module::Build::YAML->read('MYMETA.yml');
is_deeply( $mymeta2->[0]{author}, [ 'John Gault' ],
"MYMETA preserved META modifications"
);



}

#########################

# Test cleanup
{
my $output = stdout_stderr_of sub { $dist->run_build('distcheck') };
like($output, qr/Creating a temporary 'MANIFEST.SKIP'/,
Expand All @@ -41,7 +107,11 @@ $dist->chdir_in;


{
my $output = stdout_stderr_of sub { $dist->run_build('distclean') };
my $output = stdout_of sub { $dist->run_build_pl };
like($output, qr/Creating new 'MYMETA.yml' with configuration results/,
"Ran Build.PL and saw MYMETA.yml creation message"
);
$output = stdout_stderr_of sub { $dist->run_build('distclean') };
ok( ! -f 'MYMETA.yml', "No MYMETA.yml after distclean" );
ok( ! -f 'MANIFEST.SKIP', "No MANIFEST.SKIP after distclean" );
}
Expand Down

0 comments on commit 541c530

Please sign in to comment.