dougm 01/04/17 21:36:58
Modified:Apache-Test/lib/Apache Test.pm
Log:
add Apache::TestToString class for feeding Test.pm output into a string
Revision ChangesPath
1.3 +34 -3 modperl-2.0/Apache-Test/lib/Apache/Test.pm
Index: Test.pm
===
RCS file: /home/cvs/modperl-2.0/Apache-Test/lib/Apache/Test.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Test.pm 2001/04/04 04:36:57 1.2
+++ Test.pm 2001/04/18 04:36:56 1.3
@@ -11,6 +11,12 @@
our $VERSION = '0.01';
#so Perl's Test.pm can be run inside mod_perl
+sub test_pm_refresh {
+$Test::TESTOUT = \*STDOUT;
+$Test::planned = 0;
+$Test::ntest = 1;
+}
+
sub init_test_pm {
my $r = shift;
@@ -27,9 +33,7 @@
$r->content_type('text/plain');
-$Test::TESTOUT = \*STDOUT;
-$Test::planned = 0;
-$Test::ntest = 1;
+test_pm_refresh();
}
sub plan {
@@ -51,6 +55,33 @@
}
Test::plan(@_);
+}
+
+package Apache::TestToString;
+
+sub TIEHANDLE {
+my $string = "";
+bless \$string;
+}
+
+sub PRINT {
+my $string = shift;
+$$string .= join '', @_;
+}
+
+sub start {
+tie *STDOUT, __PACKAGE__;
+Apache::Test::test_pm_refresh();
+}
+
+sub finish {
+my $s;
+{
+my $o = tied *STDOUT;
+$s = $$o;
+}
+untie *STDOUT;
+$s;
}
1;