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