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