Re: A::T :withtestmore

2004-07-14 Thread William McKee
On Tue, Jul 13, 2004 at 09:12:32AM -0400, Geoffrey Young wrote:
 the limitation here is that perl package namespaces cannot contain hyphens,
 which is not specifically mentioned but can be inferred from perlvar.pod,
 Technical Note on the Syntax of Variable Names.

Thanks for the explanation. Makes perfect sense now.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com


Re: A::T :withtestmore

2004-07-13 Thread Geoffrey Young

I changed it to bugpm.pm (and changed the package name) and it worked fine.
 
 
 Actually, changing it to bug_tm.pm works. I had forgotten to change the
 package name when I retested :(. So hyphens in response tests are a bad
 thing?

the limitation here is that perl package namespaces cannot contain hyphens,
which is not specifically mentioned but can be inferred from perlvar.pod,
Technical Note on the Syntax of Variable Names.

--Geoff


Re: A::T :withtestmore

2004-07-12 Thread Geoffrey Young

   [Sun Jul 11 16:31:59 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)
   Warning: Use of require without parentheses is ambiguous at (eval 12) 
 line 1.
   [Sun Jul 11 16:32:01 2004] [error] Undefined subroutine 
 TestApache::My::Bug::bug-tm::handler called.\n
   [Sun Jul 11 16:32:01 2004] [info] removed PID file 
 /home/william/perl/bug-reporting-skeleton-mp1/t/logs/httpd.pid (pid=2537)
 
 
 Do you see this error when you run my package?

yup.

 
 This makes me think that there may be a problem in the bug testing
 framework itself when used in conjunction with the -testmore action.

I don't think so :)

 I
 don't see a require statement in Bug.pm so am at a loss to say why this
 would be failing. I tried changing the name of bug-tm.pm to bug_tm.pm in
 case the hypen was a problem; it didn't help. Any other ideas?

I changed it to bugpm.pm (and changed the package name) and it worked fine.

--Geoff


Re: A::T :withtestmore

2004-07-10 Thread Geoffrey Young

 The problem appears to be due to headers not being sent when using
 Test::More. I found the code in Apache::Test which initializes a handler
 when `plan $r, tests = 10` is called.

you can't use Test::More on the server side (that is, from a handler, such
as you have here).  at least not with the current Apache-Test.

to do that, you need to apply the attached patch - it may have some fuzz due
to a change that I just implemented this week, but I have been using it for
a few months now and haven't had any problems (once I figured out all the
issues, that is).

so, apply the patch and read the docs in the patch and you should be good to
go.  if you have trouble getting it to apply I'll whip up a current one next
week.

oh, and keep in mind that until Test::More goes official with the features
in the (required) development version this will _not_ get integrated into
Apache-Test.  that's not to say I haven't found it stable, but rather that
we can't integrate features into our stable software that depend on an
external development API.

--Geoff
Index: Apache/Test.pm
===
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/Test.pm,v
retrieving revision 1.83
diff -u -r1.83 Test.pm
--- Apache/Test.pm	1 Jun 2004 18:21:11 -	1.83
+++ Apache/Test.pm	2 Jun 2004 00:49:20 -
@@ -17,7 +17,6 @@
 use strict;
 use warnings FATAL = 'all';
 
-use Test qw(ok skip);
 use Exporter ();
 use Config;
 use Apache::TestConfig ();
@@ -46,6 +45,48 @@
 }
 
 my $Config;
+my $real_plan;
+my @testmore;
+
+sub import {
+my $class = shift;
+
+# once Test::More always Test::More until plan() is called
+if (($_[0] and $_[0] =~ m/^-withtestmore/) || @testmore) {
+# special hoops for Test::More support
+
+$real_plan = eval { 
+
+require Test::More; 
+
+no warnings qw(numeric);
+Test::Builder-VERSION('0.18_01');
+
+# required for Test::More::import() and Apache::Test::plan()
+# if we don't do this, Test::More exports plan() anyway
+# and we get collisions.  go figure.
+@testmore = (import = [qw(!plan)]);
+
+Test::More-import(@testmore);
+
+\Test::More::plan;
+} or die -withtestmore error: $@;
+
+# clean up arguments to export_to_level
+shift;
+@EXPORT = (@test_more_exports, @Test::More::EXPORT);
+}
+else {
+# the default - Test.pm support
+
+require Test;
+Test-import(qw(ok skip));
+@testmore = ();   # reset, just in case.
+$real_plan = \Test::plan;
+}
+
+$class-export_to_level(1, undef, @_ ? @_ : @EXPORT);
+}
 
 sub config {
 $Config ||= Apache::TestConfig-thaw;
@@ -61,7 +102,7 @@
 
 if (%SubTests and not $SubTests{ $Test::ntest }) {
 for my $n (1..$nok) {
-skip skipping this subtest, 0;
+skip(skipping this subtest, 0);
 }
 return;
 }
@@ -78,10 +119,26 @@
 
 #so Perl's Test.pm can be run inside mod_perl
 sub test_pm_refresh {
-$Test::TESTOUT = \*STDOUT;
-$Test::planned = 0;
-$Test::ntest = 1;
-%Test::todo = ();
+if (@testmore) {
+
+Test::Builder-reset;
+
+Test::Builder-output(\*STDOUT);
+Test::Builder-todo_output(\*STDOUT);
+
+# this is STDOUT because Test::More seems to put 
+# most of the stuff we want on STDERR, so it ends
+# up in the error_log instead of where the user can
+# see it.   consider leaving it alone based on
+# later user reports.
+Test::Builder-failure_output(\*STDOUT);
+}
+else {
+$Test::TESTOUT = \*STDOUT;
+$Test::planned = 0;
+$Test::ntest = 1;
+%Test::todo = ();
+}
 }
 
 sub init_test_pm {
@@ -171,7 +228,7 @@
 }
 @SkipReasons = (); # reset
 
-Test::plan(@_);
+$real_plan-(@_, @testmore);
 }
 
 sub have {
@@ -783,6 +840,41 @@
 plan tests = 1;   # Test::More::plan()
 
 ok ('yes', 'testing ok');  # Test::More::ok()
+
+Now, while this works fine for standard client-side tests 
+(such as Ct/basic.t), the more advanced features of IApache::Test
+require using ITest::More as the sole driver behind the scenes.
+
+Should you choose to use ITest::More as the backend for
+server-based tests (such as Ct/response/TestMe/basic.pm) you will
+need to use the C-withtestmore action tag:
+
+use Apache::Test qw(-withtestmore);
+
+sub handler {
+
+my $r = shift;
+
+plan $r, tests = 1;   # Test::More::plan() with
+   # Apache::Test features
+
+ok ('yes', 'testing ok');  # Test::More::ok()
+}
+
+C-withtestmore tells IApache::Test to use ITest::More
+instead of ITest.pm behind the scenes.  Note that you are not
+required to Cuse Test::More yourself with the C-withtestmore
+option and that the Cuse Test::More tests 

Re: A::T :withtestmore

2004-07-10 Thread Geoffrey Young


William McKee wrote:
 Hi Geoff,
 
 Thanks for the info and the patch. I applied the patch without a problem
 and then went to install the developer release of T::M. Dost my eyes
 decieve me or does that say it was last updated on November 11, 2002?
 That's a long release cycle.

indeed.

 
 At any rate, I installed the latest copy of T::M and read your
 directions in the patch. 

I couldn't get that patch to apply to current cvs.

 However, I'm still not getting the expected
 results. I suppose that could be the fuzz factor you mentioned but put
 together a new version of my test package in case you want to see if I'm
 just doing something stupid[1].

well, I get the same results, and I can't see offhand what you are doing
wrong.  but I started a tarball from scratch and was able to get it working
with no problem at all.  so, try this tarball

  http://perl.apache.org/~geoff/testmore-geoff.tar.gz

which includes a new patch against current cvs.  after installing
Test-Simple-0.48_01 I get the expected output:

server localhost.localdomain:8529 started
t/geoff/foo1..1
# Using Apache/Test.pm version 1.13
ok 1 - use Apache::Constants;
ok
All tests successful.

note (among other things) the lack of Test.pm verbose headers.

 
 I understand that you can't release this code until T::M is released but
 considering that T::M may be a bit longer baking, an additional caveat
 in the A::T pod would be useful in case T::M doesn't get released before
 the next release of A::T. I've attached a patch against the pristine
 version of 1.12.

I thought I mentioned something like that someplace?  oh, well... yeah, I'll
look it over and make sure the docs are better.

--Geoff