Author: dagolden
Date: Tue Nov 24 07:05:11 2009
New Revision: 13598
Modified:
Module-Build/trunk/t/mymeta.t
Log:
add (failing) tests that demonstrate MYMETA failings
Modified: Module-Build/trunk/t/mymeta.t
==============================================================================
--- Module-Build/trunk/t/mymeta.t (original)
+++ Module-Build/trunk/t/mymeta.t Tue Nov 24 07:05:11 2009
@@ -3,14 +3,29 @@
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;
@@ -18,17 +33,68 @@
# 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'/,
@@ -41,7 +107,11 @@
{
- 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" );
}