I think all kind of refactoring would be great. One thing I wanted to do for tests again vhosts, is to add this function next to module2path():
sub module2url { my $module = shift; my $scheme = shift || "http";
Apache::TestRequest::module($module); my $config = Apache::Test::config(); my $hostport = Apache::TestRequest::hostport($config); my $path = Apache::TestRequest::module2path($module); return "$scheme://$hostport$path"; }
and then replace the long craft used a lot in the modperl tests, so now one can write a simple:
my $module = "Foo::bar"; { my $path = Apache::TestRequest::module2path($module); GET $path; # GET "/Foo__bar" } { my $url = Apache::TestRequest::module2url($module); GET $url; # GET "http://localhost:8545/Foo__bar" }
After another look at things like t/merge.t, it looks like there are at least 2 different use cases for module2perl.
1) The $module sent to module2perl will be sent to ::module() and will be the same as the path. This is your first example:
Foo::Bar => /Foo__Bar
2) The $module sent to module2perl will be sent to ::module(), but a DIFFERENT path is required; like in merge3.t where the path == '/merge3/ != TestModperl::merge
What about make mopdeul2url have a hashref as the second arg in which we can override $path, and of course $scheme
Apache::TestRequest::module2path('TestModePerl::merge', { scheme => 'https', path => '/merge3/ }
Of course it should take the necessary precautions for when / is and isn't included, etc.
-=Chris