Currently Test::Builder does not print anything
( plan, use_ok results, etc ) if $^C is true. However to test
B::C I'd like to have a way to force the output.

Reason:
----
#!perl

BEGIN {
    print "1..2\n";
    print "ok 1\n";
}

print "ok 2\n";
----

is failing because the
1..2
ok 1
is printed at compile time, and the resulting executable
prints just
ok 2

I have modified perlcc to take a --testsuite switch that
enables BEGIN output replay: it saves the compile time output,
and adds to the .c file 
eval_pv( "print qq{$compile_time_output}" );
However Test::Builder is inhibiting any output if $^C is true,
so most test using Test::Simple/Test::More are failing when
compiled with B::C

My local modification to T::B is

--- ./lib/Test/Builder.pm.orig  Wed Nov 21 15:26:48 2001
+++ ./lib/Test/Builder.pm       Sun Dec 30 16:52:42 2001
@@ -569,5 +569,5 @@
 
     # Prevent printing headers when compiling (i.e. -c)
-    return if $^C;
+    return if $^C && !$ENV{I_WANT_BEGIN_OUT};
 
     # Escape each line with a #.
@@ -600,5 +600,5 @@
     # Prevent printing headers when only compiling.  Mostly for when
     # tests are deparsed with B::Deparse
-    return if $^C;
+    return if $^C && !$ENV{I_WANT_BEGIN_OUT};
 
     local($\, $", $,) = (undef, ' ', '');
@@ -681,5 +681,5 @@
 }
 
-unless( $^C ) {
+unless( $^C && !$ENV{I_WANT_BEGIN_OUT}) {
     # We dup STDOUT and STDERR so people can change them in their
     # test suites while still getting normal test output.

I don't care for the variable name, but I'd really like
to have this feature.

Regards
Mattia

Reply via email to