stas        2004/09/04 11:07:36

  Modified:    t/conf   extra.conf.in
               t/response/TestApache util.pm
  Log:
  fix the test to run under UTF-8 locales
  
  Revision  Changes    Path
  1.15      +4 -0      modperl-2.0/t/conf/extra.conf.in
  
  Index: extra.conf.in
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/conf/extra.conf.in,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -u -r1.14 -r1.15
  --- extra.conf.in     21 Aug 2004 20:13:39 -0000      1.14
  +++ extra.conf.in     4 Sep 2004 18:07:36 -0000       1.15
  @@ -84,3 +84,7 @@
       SetHandler modperl
       PerlResponseHandler Apache::Status
   </Location>
  +
  +# for TestApache::util
  +PerlPassEnv LC_CTYPE
  +PerlPassEnv LC_TIME
  
  
  
  1.8       +26 -5     modperl-2.0/t/response/TestApache/util.pm
  
  Index: util.pm
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/t/response/TestApache/util.pm,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -u -r1.7 -r1.8
  --- util.pm   25 Aug 2004 19:49:23 -0000      1.7
  +++ util.pm   4 Sep 2004 18:07:36 -0000       1.8
  @@ -5,6 +5,16 @@
   use strict;
   use warnings FATAL => 'all';
   
  +# to fully test this test the following locale settings need to be run:
  +#
  +# some /^en_/ locale, e.g. /^en_GB*
  +# LC_CTYPE=en_GB.UTF-8 LC_TIME=en_GB.UTF-8 t/TEST -verbose apache/util.t
  +# LC_CTYPE=en_GB       LC_TIME=en_GB       t/TEST -verbose apache/util.t
  +#
  +# some non-/^en_/ locale, e.g. ru_RU
  +# LC_CTYPE=ru_RU.UTF-8 LC_TIME=ru_RU.UTF-8 t/TEST -verbose apache/util.t
  +# LC_CTYPE=ru_RU       LC_TIME=ru_RU       t/TEST -verbose apache/util.t
  +
   # regex matching (LC_CTYPE) of strftime-like (LC_TIME) strings
   use locale;
   
  @@ -18,11 +28,11 @@
   
   use Apache::Const -compile => 'OK';
   
  -# XXX: need to use PerlPassEnv to get these %ENV vars
  -my $locale = $ENV{LANG} || $ENV{LC_TIME} || '';
  -# XXX: will any en_XXX work with http_parse? try setlocale?
  -# XXX: should we set $ENV{LANG} to en_US instead of skipping?
  -my $parse_time_ok = $locale =~ /^en_/ ? 1 : 0;
  +# those are passed via PerlPassEnv
  +my $locale = $ENV{LC_TIME} || '';
  +
  +my $parse_time_ok  = $locale =~ /^en_/   ? 1 : 0;
  +my $locale_is_utf8 = $locale =~ /UTF-8$/ ? 1 : 0;
   
   sub handler {
       my $r = shift;
  @@ -96,6 +106,17 @@
           ok t_cmp $ptime, $time, $comment;
       }
       else {
  +        if ($locale_is_utf8) {
  +            if (have_min_perl_version(5.008)) {
  +                require Encode;
  +                # perl doesn't know yet that $fmtdate is a utf8 string
  +                $fmtdate = Encode::decode_utf8($fmtdate);
  +            }
  +            else {
  +                skip "Skip locale $locale needs perl 5.8.0+", 0;
  +                return;
  +            }
  +        }
           ok t_cmp $fmtdate, $fmtdate_re, $comment;
       }
   }
  
  
  

Reply via email to