[Rt-commit] rt branch, 4.2/pass-apache-tests, created. rt-4.0.6-498-gac6ebef

Alex Vandiver alexmv at bestpractical.com
Fri Aug 31 17:35:55 EDT 2012


The branch, 4.2/pass-apache-tests has been created
        at  ac6ebef343ef6391aec6879702ab09081da2e5f2 (commit)

- Log -----------------------------------------------------------------
commit 2bb0610b9d3872fcdcfea02580a304d21c7bfdd4
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Aug 31 14:55:42 2012 -0400

    Ensure that BASIC_AUTH in testing Apache configs always has a value
    
    The interpolation done on t/data/configs/ files requires that all
    interpolated keys actually exist in %opt.  Under Apache testing, every
    test whch didn't ask for auth hence failed, as 7e0cd14 caused such tests
    to no longer supply a BASIC_AUTH value.

diff --git a/lib/RT/Test/Apache.pm b/lib/RT/Test/Apache.pm
index 28f2615..cf9865f 100644
--- a/lib/RT/Test/Apache.pm
+++ b/lib/RT/Test/Apache.pm
@@ -126,12 +126,12 @@ sub start_server {
         rt_site_config => $ENV{'RT_SITE_CONFIG'},
         load_modules   => $info{load_modules},
     );
-    if ($config{basic_auth}) {
-        if ($config{basic_auth} eq 'anon') {
-            $opt{basic_auth} = $self->basic_auth_anon;
-        } else {
-            $opt{basic_auth} = $self->basic_auth;
-        }
+    if (not $config{basic_auth}) {
+        $opt{basic_auth} = "";
+    } elsif ($config{basic_auth} eq 'anon') {
+        $opt{basic_auth} = $self->basic_auth_anon;
+    } else {
+        $opt{basic_auth} = $self->basic_auth;
     }
     foreach (qw(log pid lock)) {
         $opt{$_ .'_file'} = File::Spec->catfile(

commit 920fb1ff854d29d448f17b8e3b11109d057f2683
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Aug 31 15:37:42 2012 -0400

    Unify install-mode testing technique
    
    This causes t/web/install.t to no longer fail when run with
    RT_TEST_WEB_HANDLER set, as well as being more true-to-life, as
    t/web/installer.t is.

diff --git a/t/web/install.t b/t/web/install.t
index 1e85f12..17aec93 100644
--- a/t/web/install.t
+++ b/t/web/install.t
@@ -2,8 +2,12 @@ use strict;
 use warnings;
 use File::Spec;
 use utf8;
-use RT::Test tests => 60, actual_server => 1, noinitialdata => 1;
-RT->InstallMode(1);
+
+$ENV{RT_TEST_WEB_HANDLER} = 'plack+rt-server';
+use RT::Test
+    tests     => undef,
+    nodb      => 1,
+    server_ok => 1;
 
 my $dbname     = 'rt4test_install_xxx';
 my $rtname     = 'rttestname';
@@ -19,6 +23,9 @@ my $owner = 'root at localhost';
 unlink File::Spec->catfile( $RT::VarPath, $dbname );
 
 my ( $url, $m ) = RT::Test->started_ok;
+$m->warning_like(qr/If this is a new installation of RT/,
+                 "Got startup warning");
+
 my ($port) = $url =~ /:(\d+)/;
 $m->get_ok($url);
 
@@ -163,3 +170,5 @@ is( $config->Get('CommentAddress'), $comment, 'comment address in config' );
 
 unlink File::Spec->catfile( $RT::VarPath, $dbname );
 
+undef $m;
+done_testing;

commit a340203378239b430086e09fe4ba99770b736ba1
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Aug 31 16:07:50 2012 -0400

    Rewrite RT_SiteConfig.pm entirely when setting options during testing
    
    Because only the first Set(...) takes effect, tests which set a value
    twice failed when run under Apache -- the only time that the external
    RT_Siteconfig is used during testing.  Instead of blindly appending to
    the file, read it back in in its entirety, strip out any previous
    Set(...) calls to the same variable, and then re-write it.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 385ddf7..cda2e2c 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -374,14 +374,36 @@ sub set_config_wrapper {
                 SCALAR => '$',
             );
             my $sigil = $sigils{$type} || $sigils{'SCALAR'};
-            open( my $fh, '>>', $tmp{'config'}{'RT'} )
+            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+$//;
-            print $fh
-                "\nSet(${sigil}${name}, \@{". $dump ."});\n1;\n";
+            $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 ) {

commit ac6ebef343ef6391aec6879702ab09081da2e5f2
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Aug 31 17:21:40 2012 -0400

    Move locale loading earlier, so we don't cache false negative
    
    On the first call to Locale::Maketext->get_handle, the list of locales
    is inspected, and RT::I18N::xx is attempted to be loaded to each
    possible handle -- and load success/failure is cached indefinitely.
    Thus, if a localization happens before RT::I18N->Init has been called
    (which creates those classes), RT will forever assume that it does not
    have any of the tried localizations.
    
    This is not an issue during real deployment, as RT::I18N->Init is called
    in RT->Init, which guaranteedly comes before any localizations that RT
    might try.  However, in tests, we bootstrap the database into existance
    in RT::Test->import _before_ calling RT::I18N->Init, which (in forked or
    in-process test servers) caches a false negative for the 'en'
    localization.  This causes "Homepage" to not be localized to "Home" in
    the default locale.
    
    Note that non-en localizations are unaffected, as they are not tried
    during the initial bootstrap process, and hence they do not get a false
    negative cache.
    
    During testing, load the I18N files just before bootstrapping the
    database.

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index cda2e2c..900f65e 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -135,6 +135,7 @@ sub import {
     RT::InitPluginPaths();
     RT::InitClasses();
 
+    RT::I18N->Init();
     $class->bootstrap_db( %args );
 
     __reconnect_rt()
@@ -144,7 +145,6 @@ sub import {
 
     RT->Plugins;
 
-    RT::I18N->Init();
     RT->Config->PostLoadCheck;
 
     $class->set_config_wrapper;
diff --git a/t/web/mobile.t b/t/web/mobile.t
index ee5b678..3f32e49 100644
--- a/t/web/mobile.t
+++ b/t/web/mobile.t
@@ -47,7 +47,7 @@ for my $agent (@agents) {
 
 $m->submit_form( fields => { user => 'root', pass => 'password' } );
 is( $m->uri, $url . '/m/', 'logged in via mobile ui' );
-ok( $m->find_link( text => 'Homepage' ), 'has homepage link, so really logged in' );
+ok( $m->find_link( text => 'Home' ), 'has homepage link, so really logged in' );
 
 diag "create some tickets";
 $m->follow_link_ok( { text => 'New ticket' } );
@@ -135,7 +135,7 @@ $m->content_contains( 'reply 1', 'has replied content' );
 $m->content_contains( 'reply 2', 'has replied content' );
 
 diag "create another ticket in queue foo";
-$m->follow_link_ok( { text => 'Homepage' } );
+$m->follow_link_ok( { text => 'Home' } );
 is( $m->uri, "$url/m/", 'main mobile page' );
 $m->follow_link_ok( { text => 'New ticket' } );
 like( $m->uri, qr'/m/ticket/select_create_queue', 'queue select page' );
@@ -156,7 +156,7 @@ like( $m->uri, qr'/m/ticket/show', 'ticket show page' );
 $m->content_contains( 'cfbar', 'has cf name' );
 $m->content_contains( 'cfvalue', 'has cf value' );
 
-$m->follow_link_ok( { text => 'Homepage' } );
+$m->follow_link_ok( { text => 'Home' } );
 is( $m->uri, "$url/m/", 'main mobile page' );
 
 diag "test unowned tickets link";
@@ -204,7 +204,7 @@ is( $m->uri, "$url/m/", 'still in mobile' );
 $m->submit_form( fields => { user => 'root', pass => 'password' } );
 
 diag "test notmobile link";
-$m->follow_link_ok( { text => 'Homepage' } );
+$m->follow_link_ok( { text => 'Home' } );
 $m->follow_link_ok( { text => 'Not using a mobile browser?' } );
 is( $m->uri, $url . '/', 'got full ui' );
 

-----------------------------------------------------------------------


More information about the Rt-commit mailing list