Fixed immediate dependence on DBI
[dbsrgits/DBM-Deep.git] / Build.PL
CommitLineData
ffed8b01 1use Module::Build;
2
3use strict;
67e9b86f 4use warnings FATAL => 'all';
ffed8b01 5
67e9b86f 6my $class = Module::Build->subclass(
7 class => "Module::Build::Custom",
8 code => <<'SUBCLASS' );
9
10sub 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 }
bac1b5d5 17 foreach my $name ( qw( LONG_TESTS TEST_SQLITE ) ) {
18 $ENV{$name} = 1 if $self->notes( $name );
67e9b86f 19 }
67e9b86f 20}
21SUBCLASS
22
23my $build = $class->new(
ffed8b01 24 module_name => 'DBM::Deep',
25 license => 'perl',
26 requires => {
2120a181 27 'perl' => '5.006_000',
a8fdabda 28 'Fcntl' => '0.01',
a8fdabda 29 'Scalar::Util' => '1.14',
e00d0eb3 30 'Digest::MD5' => '1.00',
ffed8b01 31 },
ffed8b01 32 build_requires => {
d0c365a5 33 'File::Path' => '0.01',
34 'File::Temp' => '0.01',
d245280e 35 'Pod::Usage' => '1.3',
0e3e3555 36 'Test::More' => '0.88',
17ca2cc9 37 'Test::Deep' => '0.095',
e9b0b5f0 38 'Test::Warn' => '0.08',
ffed8b01 39 'Test::Exception' => '0.21',
151e0077 40 'IO::Scalar' => '0.01',
ffed8b01 41 },
42 create_makefile_pl => 'traditional',
43 add_to_cleanup => [
e00d0eb3 44 'META.yml', '*.bak', '*.gz', 'Makefile.PL', 'cover_db',
ffed8b01 45 ],
2ec46b24 46 test_files => 't/??_*.t',
67e9b86f 47 auto_features => {
bac1b5d5 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',
67e9b86f 57 requires => {
58 'DBI' => '1.5',
59 'DBD::mysql' => '4.001',
60 },
61 },
62 },
ffed8b01 63);
64
67e9b86f 65if ( $build->y_n( "Run the long-running tests", 'n' ) ) {
66 $build->notes( 'LONG_TESTS' => 1 );
67}
68
bac1b5d5 69if ( $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
75if ( $build->features( 'mysql_engine' ) ) {
76 if ( $build->y_n( "Run the tests against the DBI engine via MySQL?", 'n' ) ) {
67e9b86f 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
ffed8b01 92$build->create_build_script;