[Rt-commit] rt branch, 4.2/shredder-only-sqlite, created. rt-4.2.3-90-gc0b4219
Alex Vandiver
alexmv at bestpractical.com
Fri Apr 18 14:25:05 EDT 2014
The branch, 4.2/shredder-only-sqlite has been created
at c0b42197e6c17d542efa654e3978e92d5d4499b3 (commit)
- Log -----------------------------------------------------------------
commit f90fadb64c78fbb870d273b1634c23b96f998fb4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 13:42:14 2014 -0400
Skip Shredder tests on all non-SQLite databases
Shredder tests currently hardcode themselves to run against a SQLite
database. Until such time as the comparison functions work correctly on
other databases, stop pretending that the tests are running on them.
diff --git a/lib/RT/Test/Shredder.pm b/lib/RT/Test/Shredder.pm
index 480dfc9..c67c2ed 100644
--- a/lib/RT/Test/Shredder.pm
+++ b/lib/RT/Test/Shredder.pm
@@ -106,7 +106,15 @@ Savepoints are named and you can create two or more savepoints.
sub import {
my $class = shift;
- $class->SUPER::import(@_);
+
+ $class->SUPER::import(@_, tests => undef );
+
+ RT::Test::plan( skip_all => 'Shredder tests only work on SQLite' )
+ unless RT->Config->Get('DatabaseType') eq 'SQLite';
+
+ my %args = @_;
+ RT::Test::plan( tests => $args{'tests'} ) if $args{tests};
+
$class->export_to_level(1);
}
commit 07f5c4d9f71c538e4a147d6cef0f2715c70da60f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 13:44:51 2014 -0400
bootstrap_more_config is now unnecessary, as tests only actually run on sqlite
An adjustment to db_name is necessary, to point to where RT's standard
testing framework writes the SQLite database during testing. This
exposes that the test suite writes the database to the installed
$VarPath, rather than the temporary testing directory.
diff --git a/lib/RT/Test/Shredder.pm b/lib/RT/Test/Shredder.pm
index c67c2ed..63a1ef7 100644
--- a/lib/RT/Test/Shredder.pm
+++ b/lib/RT/Test/Shredder.pm
@@ -120,40 +120,16 @@ sub import {
=head1 FUNCTIONS
-=head2 RT CONFIG
-
-=head3 rewrite_rtconfig
-
-Call this sub after C<RT::LoadConfig>. It changes the RT config
-options necessary to switch to a local SQLite database.
-
-=cut
-
-sub bootstrap_more_config {
- my $self = shift;
- my $config = shift;
-
- print $config <<'END';
-Set($DatabaseType , 'SQLite');
-Set($DatabaseHost , 'localhost' );
-Set($DatabaseRTHost , 'localhost' );
-Set($DatabasePort , '' );
-END
-
- print $config "Set(\$DatabaseName, '". $self->db_name ."');\n";
- return;
-}
-
=head2 DATABASES
=head3 db_name
Returns the absolute file path to the current DB.
-It is C<<RT::Test->temp_directory . 'main.db'>>.
+It is C<<$RT::VarPath . "rt4test" >>.
=cut
-sub db_name { return File::Spec->catfile((shift)->temp_directory, "main.db") }
+sub db_name { return File::Spec->catfile($RT::VarPath, RT->Config->Get("DatabaseName")) }
=head3 connect_sqlite
commit 7568d21f7b8bf1fdb1e3b4c0975ec2b691174b12
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 14:21:23 2014 -0400
Split the Set override into WriteSet, to allow it to be called explicitly
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 0261f42..bcbb284 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -395,6 +395,56 @@ sub set_config_wrapper {
my $old_sub = \&RT::Config::Set;
no warnings 'redefine';
+
+ *RT::Config::WriteSet = sub {
+ my ($self, $name) = @_;
+ my $type = $RT::Config::META{$name}->{'Type'} || 'SCALAR';
+ my %sigils = (
+ HASH => '%',
+ ARRAY => '@',
+ SCALAR => '$',
+ );
+ my $sigil = $sigils{$type} || $sigils{'SCALAR'};
+ open( my $fh, '<', $tmp{'config'}{'RT'} )
+ or die "Couldn't open config file: $!";
+ my @lines;
+ while (<$fh>) {
+ if (not @lines or /^Set\(/) {
+ push @lines, $_;
+ } else {
+ $lines[-1] .= $_;
+ }
+ }
+ close $fh;
+
+ # Traim trailing newlines and "1;"
+ $lines[-1] =~ s/(^1;\n|^\n)*\Z//m;
+
+ # Remove any previous definitions of this var
+ @lines = grep {not /^Set\(\s*\Q$sigil$name\E\b/} @lines;
+
+ # Format the new value for output
+ require Data::Dumper;
+ local $Data::Dumper::Terse = 1;
+ my $dump = Data::Dumper::Dumper([@_[2 .. $#_]]);
+ $dump =~ s/;?\s+\Z//;
+ push @lines, "Set( ${sigil}${name}, \@{". $dump ."});\n";
+ push @lines, "\n1;\n";
+
+ # Re-write the configuration file
+ open( $fh, '>', $tmp{'config'}{'RT'} )
+ or die "Couldn't open config file: $!";
+ print $fh $_ for @lines;
+ close $fh;
+
+ if ( @SERVERS ) {
+ warn "you're changing config option in a test file"
+ ." when server is active";
+ }
+
+ return $old_sub->(@_);
+ };
+
*RT::Config::Set = sub {
# Determine if the caller is either from a test script, or
# from helper functions called by test script to alter
@@ -404,52 +454,9 @@ sub set_config_wrapper {
my @caller = caller(1); # preserve list context
@caller = caller(0) unless @caller;
- if ( ($caller[1]||'') =~ /\.t$/) {
- my ($self, $name) = @_;
- my $type = $RT::Config::META{$name}->{'Type'} || 'SCALAR';
- my %sigils = (
- HASH => '%',
- ARRAY => '@',
- SCALAR => '$',
- );
- my $sigil = $sigils{$type} || $sigils{'SCALAR'};
- open( my $fh, '<', $tmp{'config'}{'RT'} )
- or die "Couldn't open config file: $!";
- my @lines;
- while (<$fh>) {
- if (not @lines or /^Set\(/) {
- push @lines, $_;
- } else {
- $lines[-1] .= $_;
- }
- }
- close $fh;
-
- # Traim trailing newlines and "1;"
- $lines[-1] =~ s/(^1;\n|^\n)*\Z//m;
-
- # Remove any previous definitions of this var
- @lines = grep {not /^Set\(\s*\Q$sigil$name\E\b/} @lines;
-
- # Format the new value for output
- require Data::Dumper;
- local $Data::Dumper::Terse = 1;
- my $dump = Data::Dumper::Dumper([@_[2 .. $#_]]);
- $dump =~ s/;?\s+\Z//;
- push @lines, "Set( ${sigil}${name}, \@{". $dump ."});\n";
- push @lines, "\n1;\n";
-
- # Re-write the configuration file
- open( $fh, '>', $tmp{'config'}{'RT'} )
- or die "Couldn't open config file: $!";
- print $fh $_ for @lines;
- close $fh;
-
- if ( @SERVERS ) {
- warn "you're changing config option in a test file"
- ." when server is active";
- }
- }
+ return RT::Config::WriteSet(@_)
+ if ($caller[1]||'') =~ /\.t$/;
+
return $old_sub->(@_);
};
}
commit c0b42197e6c17d542efa654e3978e92d5d4499b3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Fri Apr 18 14:22:26 2014 -0400
Store the SQLite database under the temporary directory
This must be done _after_ the initial RT_SiteConfig write, because the
DatabaseType is in RT_Config.pm, and thus only known after both
RT_Siteconfig and RT_Config have been loaded. This necessitates moving
set_config_wrapper to before the call to bootstrap_db, and valling
WriteSet explicitly, as the override used in Set only catches calls to
Set() from .t files, not from RT::Test -- and the change must be written
out, or rt-validator will not find the database in the correct location.
diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index bcbb284..1e57b55 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -159,6 +159,8 @@ sub import {
RT::InitClasses();
RT::I18N->Init();
+
+ $class->set_config_wrapper;
$class->bootstrap_db( %args );
__reconnect_rt()
@@ -170,8 +172,6 @@ sub import {
RT->Config->PostLoadCheck;
- $class->set_config_wrapper;
-
my $screen_logger = $RT::Logger->remove( 'screen' );
require Log::Dispatch::Perl;
$RT::Logger->add( Log::Dispatch::Perl->new
@@ -485,6 +485,11 @@ sub bootstrap_db {
}
my $db_type = RT->Config->Get('DatabaseType');
+
+ if ($db_type eq "SQLite") {
+ RT->Config->WriteSet( DatabaseName => File::Spec->catfile( $self->temp_directory, "rt4test" ) );
+ }
+
__create_database();
__reconnect_rt('as dba');
$RT::Handle->InsertSchema;
diff --git a/lib/RT/Test/Shredder.pm b/lib/RT/Test/Shredder.pm
index 63a1ef7..8602fa8 100644
--- a/lib/RT/Test/Shredder.pm
+++ b/lib/RT/Test/Shredder.pm
@@ -125,11 +125,11 @@ sub import {
=head3 db_name
Returns the absolute file path to the current DB.
-It is C<<$RT::VarPath . "rt4test" >>.
+It is C<<RT::Test->temp_directory . "rt4test" >>.
=cut
-sub db_name { return File::Spec->catfile($RT::VarPath, RT->Config->Get("DatabaseName")) }
+sub db_name { return RT->Config->Get("DatabaseName") }
=head3 connect_sqlite
-----------------------------------------------------------------------
More information about the rt-commit
mailing list