Apply some changes
[dbsrgits/DBM-Deep.git] / Build.PL
1 use Module::Build 0.28; # for prepare_metadata
2
3 use strict;
4 use warnings FATAL => 'all';
5
6 my $build = Module::Build->subclass(
7     class => "Module::Build::Custom",
8     code => '
9         sub prepare_metadata {
10             my $node = shift->SUPER::prepare_metadata(@_);
11             my $ver = $node->{version};
12             $_->{version} = $ver for values %{$node->{provides}};
13             $node;
14         }
15
16         sub ACTION_test {
17             my $self = shift;
18             if ( $self->notes('TEST_MYSQL_DSN') ) {
19                 $ENV{$_} = $self->notes($_) for qw(
20                     TEST_MYSQL_DSN TEST_MYSQL_USER TEST_MYSQL_PASS
21                 );
22             }
23             foreach my $name ( qw( LONG_TESTS TEST_SQLITE ) ) {
24                 $ENV{$name} = 1 if $self->notes( $name );
25             }
26
27             $self->SUPER::ACTION_test( @_ );
28         }
29     ',
30 )->new(
31     module_name => 'DBM::Deep',
32     license => 'perl',
33     requires => {
34         'perl'              => '5.006_000',
35         'Fcntl'             => '0.01',
36         'Scalar::Util'      => '1.14',
37         'Digest::MD5'       => '1.00',
38     },
39     build_requires => {
40         'File::Path'      => '0.01',
41         'File::Temp'      => '0.01',
42         'Pod::Usage'      => '1.3',
43         'Test::More'      => '0.88',
44         'Test::Deep'      => '0.095',
45         'Test::Warn'      => '0.08',
46         'Test::Exception' => '0.21',
47         'IO::Scalar'      => '0.01',
48     },
49     create_makefile_pl => 'traditional',
50     add_to_cleanup => [
51         'META.yml', '*.bak', '*.gz', 'Makefile.PL', 'cover_db',
52     ],
53     test_files => 't/??_*.t',
54     auto_features => {
55         sqlite_engine => {
56             description => 'DBI support via SQLite',
57             requires => {
58                 'DBI'         => '1.5',
59                 'DBD::SQLite' => '1.25',
60             },
61         },
62         mysql_engine => {
63             description => 'DBI support via MySQL',
64             requires => {
65                 'DBI'        => '1.5',
66                 'DBD::mysql' => '4.001',
67             },
68         },
69     },
70 );
71
72 if ( $build->y_n( "Run the long-running tests", 'n' ) ) {
73     $build->notes( 'LONG_TESTS' => 1 );
74 }
75
76 if ( $build->features( 'sqlite_engine' ) ) {
77     if ( $build->y_n( "Run the tests against the DBI engine via SQLite?", 'n' ) ) {
78         $build->notes( 'TEST_SQLITE' => 1 );
79     }
80 }
81
82 if ( $build->features( 'mysql_engine' ) ) {
83     if ( $build->y_n( "Run the tests against the DBI engine via MySQL?", 'n' ) ) {
84         my ($dsn, $user, $pass) = ('') x 3;
85         $dsn = $build->prompt( "\tWhat is the full DSN (for example 'dbi:mysql:test')" );
86         if ( $dsn ) {
87             $user = $build->prompt( "\tWhat is the username?" );
88             if ( $user ) {
89                 $pass = $build->prompt( "\tWhat is the password?" );
90             }
91         }
92
93         $build->notes( 'TEST_MYSQL_DSN'  => $dsn );
94         $build->notes( 'TEST_MYSQL_USER' => $user );
95         $build->notes( 'TEST_MYSQL_PASS' => $pass );
96     }
97 }
98
99 $build->create_build_script;