e691c3f2dcdf80c068c58553366e0860fde5e052
[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::More'      => '0.88', # done_testing
47         'Test::Exception' => '0.21',
48         'IO::Scalar'      => '0.01',
49     },
50     create_makefile_pl => 'traditional',
51     add_to_cleanup => [
52         'META.yml', '*.bak', '*.gz', 'Makefile.PL', 'cover_db',
53     ],
54     test_files => 't/??_*.t',
55     auto_features => {
56         sqlite_engine => {
57             description => 'DBI support via SQLite',
58             requires => {
59                 'DBI'         => '1.5',
60                 'DBD::SQLite' => '1.25',
61             },
62         },
63         mysql_engine => {
64             description => 'DBI support via MySQL',
65             requires => {
66                 'DBI'        => '1.5',
67                 'DBD::mysql' => '4.001',
68             },
69         },
70     },
71 );
72
73 if ( $build->y_n( "Run the long-running tests", 'n' ) ) {
74     $build->notes( 'LONG_TESTS' => 1 );
75 }
76
77 if ( $build->features( 'sqlite_engine' ) ) {
78     if ( $build->y_n( "Run the tests against the DBI engine via SQLite?", 'n' ) ) {
79         $build->notes( 'TEST_SQLITE' => 1 );
80     }
81 }
82
83 if ( $build->features( 'mysql_engine' ) ) {
84     if ( $build->y_n( "Run the tests against the DBI engine via MySQL?", 'n' ) ) {
85         my ($dsn, $user, $pass) = ('') x 3;
86         $dsn = $build->prompt( "\tWhat is the full DSN (for example 'dbi:mysql:test')" );
87         if ( $dsn ) {
88             $user = $build->prompt( "\tWhat is the username?" );
89             if ( $user ) {
90                 $pass = $build->prompt( "\tWhat is the password?" );
91             }
92         }
93
94         $build->notes( 'TEST_MYSQL_DSN'  => $dsn );
95         $build->notes( 'TEST_MYSQL_USER' => $user );
96         $build->notes( 'TEST_MYSQL_PASS' => $pass );
97     }
98 }
99
100 $build->create_build_script;