William McKee wrote:
Hi Stas,

I'm working with an intern to create a graphical depiction of the A::T
process. As we were working on this image, I came across the following
lines in your testing doc on perl.apache.org[1]:

------------------
The corresponding request part of the test is named just like the
response part, using the following translation:

  $response_test =~ s|t/[^/]+/Test([^/]+)/(.*).pm$|t/\L$1\E/$2.t|;

  so for example t/response/TestApache/write.pm becomes:
  t/apache/write.t.
------------------

Is this still accurate? My experience is that
t/response/MyModule/mytest.pm becomes t/mymodule/mytest.t. Could you
please resolve the differences for me?

[1] http://perl.apache.org/docs/general/testing/testing.html#Developing_Response_only_Part_of_a_Test

Right, it has become more flexible since I wrote that. This is somewhat closer:

s{^ t/ [^/]+ / (?:Test)*([^/]+) / (.*).pm $}
 {  t/ \L$1 / $2.t}ix;

/^Test/ part is removed and it's all lower cased. Notice that Geoff has changed the cvs version to support multilevel names as well, so now you get:

% perl -le '$_ = "t/response/TestApache/write.pm"; \
s{t/[^/]+/(?:Test)*([^/]+)/(.*).pm$}{t/\L$1/$2.t}; print'
t/apache/write.t

% perl -le '$_ = "t/response/MyApache/write.pm"; \
s{t/[^/]+/(?:Test)*([^/]+)/(.*).pm$}{t/\L$1/$2.t}; print'
t/myapache/write.t

% perl -le '$_ = "t/response/TestApache/Mar/write.pm"; \
s{t/[^/]+/(?:Test)*([^/]+)/(.*).pm$}{t/\L$1/$2.t}; print'
t/apache/mar/write.t

But in reality it does something similar to:

my $path = "t/response/TestApache/write.pm";
(my $module = $path) =~ s{t/[^/]+/(.*).pm}{$1.t};
my $path = join '/', 't',
            map { s/^test//i; lc $_ } split '::', $module;
print "$path\n";

I'll fix the doc. Thanks for this alert, William.

--
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Reply via email to