[RFC] Switch to make Test::Builder output even if $^C ( for B::C )

2002-01-02 Thread Mattia Barbon

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



Testing Tests

2002-01-02 Thread Mark Fowler

Is there any commonly accepted knowledge about how one should write tests
for "Test"  modules that one might construct using Test::Builder?  In
particular, how does one test that one of your new test fails when it
should?

I did have an idea about how nice it would be if you could call a method 
in Test::Builder that would cause the next call to ok() to fail if it 
should pass and vice versa (and return true where it would have returned 
true and false when it would have returned true.) 

Later.

Mark.

-- 
s''  Mark Fowler London.pm   Bath.pm
 http://www.twoshortplanks.com/  [EMAIL PROTECTED]
';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/  +/
){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}