Permalink
Browse files

removed redundancy of getting notes twice; use strict in generated mo…

…dule so All.t passes
  • Loading branch information...
sb10 committed Mar 31, 2011
1 parent 793d566 commit 35ed80063fb69c2d72c73afb2b05e9b68af48af1
Showing with 14 additions and 13 deletions.
  1. +14 −13 build_lib/MyBuild.pm
View
@@ -30,6 +30,9 @@ sub create_vrconfig_file {
open( my $file, '>', $path ) or die "Cannot write to '$path': $!\n";
printf $file <<'END_HERE', $dd->Dump();
package VRTrack::Testconfig;
+use strict;
+use warnings;
+
my $db_config;
%s;
@@ -44,27 +47,25 @@ END_HERE
}
sub create_database {
- my ($self, $dbname) = @_;
- my $config = $self->notes( 'db_config' );
- if ($config) {
- my @sql = VRTrack::VRTrack->schema();
- open(my $mysqlfh, "| mysql -h$config->{host} -u$config->{user} -p$config->{password} -P$config->{port}") || die "could not connect to database for testing\n";
- print $mysqlfh "drop database if exists $config->{test_db};\n";
- print $mysqlfh "create database $config->{test_db};\n";
- print $mysqlfh "use $config->{test_db};\n";
- foreach my $sql (@sql) {
- print $mysqlfh $sql;
- }
- close($mysqlfh);
+ my ($self, $config) = @_;
+
+ my @sql = VRTrack::VRTrack->schema();
+ open(my $mysqlfh, "| mysql -h$config->{host} -u$config->{user} -p$config->{password} -P$config->{port}") || die "could not connect to database for testing\n";
+ print $mysqlfh "drop database if exists $config->{test_db};\n";
+ print $mysqlfh "create database $config->{test_db};\n";
+ print $mysqlfh "use $config->{test_db};\n";
+ foreach my $sql (@sql) {
+ print $mysqlfh $sql;
}
+ close($mysqlfh);
}
sub ACTION_test {
my $self = shift;
my $config = $self->notes( 'db_config' );
if ($config) {
eval {
- $self->create_database( $config->{test_db} );
+ $self->create_database( $config );
};
if ($@){
print $@;

0 comments on commit 35ed800

Please sign in to comment.