Fixed bug in Build.PL and pre-seeded expected activity for this release
[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     $self->SUPER::ACTION_test( @_ );
22 }
23 SUBCLASS
24
25 my $build = $class->new(
26     module_name => 'DBM::Deep',
27     license => 'perl',
28     requires => {
29         'perl'              => '5.006_000',
30         'Fcntl'             => '0.01',
31         'Scalar::Util'      => '1.14',
32         'Digest::MD5'       => '1.00',
33     },
34     build_requires => {
35         'File::Path'      => '0.01',
36         'File::Temp'      => '0.01',
37         'Pod::Usage'      => '1.3',
38         'Test::More'      => '0.88',
39         'Test::Deep'      => '0.095',
40         'Test::Warn'      => '0.08',
41         'Test::Exception' => '0.21',
42         'IO::Scalar'      => '0.01',
43     },
44     create_makefile_pl => 'traditional',
45     add_to_cleanup => [
46         'META.yml', '*.bak', '*.gz', 'Makefile.PL', 'cover_db',
47     ],
48     test_files => 't/??_*.t',
49     auto_features => {
50         sqlite_engine => {
51             description => 'DBI support via SQLite',
52             requires => {
53                 'DBI'         => '1.5',
54                 'DBD::SQLite' => '1.25',
55             },
56         },
57         mysql_engine => {
58             description => 'DBI support via MySQL',
59             requires => {
60                 'DBI'        => '1.5',
61                 'DBD::mysql' => '4.001',
62             },
63         },
64     },
65 );
66
67 if ( $build->y_n( "Run the long-running tests", 'n' ) ) {
68     $build->notes( 'LONG_TESTS' => 1 );
69 }
70
71 if ( $build->features( 'sqlite_engine' ) ) {
72     if ( $build->y_n( "Run the tests against the DBI engine via SQLite?", 'n' ) ) {
73         $build->notes( 'TEST_SQLITE' => 1 );
74     }
75 }
76
77 if ( $build->features( 'mysql_engine' ) ) {
78     if ( $build->y_n( "Run the tests against the DBI engine via MySQL?", 'n' ) ) {
79         my ($dsn, $user, $pass) = ('') x 3;
80         $dsn = $build->prompt( "\tWhat is the full DSN (for example 'dbi:mysql:test')" );
81         if ( $dsn ) {
82             $user = $build->prompt( "\tWhat is the username?" );
83             if ( $user ) {
84                 $pass = $build->prompt( "\tWhat is the password?" );
85             }
86         }
87
88         $build->notes( 'TEST_MYSQL_DSN'  => $dsn );
89         $build->notes( 'TEST_MYSQL_USER' => $user );
90         $build->notes( 'TEST_MYSQL_PASS' => $pass );
91     }
92 }
93
94 $build->create_build_script;