> On Sun, Jan 06, 2002 at 03:56:24PM +0100, Mattia Barbon wrote:
> > > Could you explain again why you need test output while compiling, I'm
> > > not quite following. Assume you had the I_WANT_OUTPUT_DURING_COMPILE
> > > environment variable could you show how you'd be using it?
> >
> > Let's say I have this lib/Bar/t/bar.t ( not usint Test::* )
> > ----
> > #!perl
> >
> > BEGIN { print "1..2\n" };
> > BEGIN { print "ok 1" };
> >
> > print "ok 2\n";
> > ----
> > This prints "1..2\nok 1\n" at compile time, and "ok 2\n"; at run
> > time. When compiled with "perlcc --testsuite bar.t", perlcc saves
> > the compile-time output, and passes to B::C the
> > -e"print qq{1..2\nok 1\n}" option ( -efoo means "eval foo just before
> > you run the program" ); so the compiled program prints
> > 1..2
> > ok 1
> > ok 2
> > and t/TEST is happy
> >
> > However lib/Foo/t/foo.t uses Test::Simple
> > ----
> > #!perl
> >
> > use Test::Simple tests => 2;
> >
> > BEGIN { use_ok('Foo') }
> >
> > ok( foo(1), "foo(1) is true" );
> > ----
> > So when compiled with B::C, $^C is set, and it does
> > not print the "1..2\nok 1\n" at all, so perlcc does not see it,
> > does not pass anything to B::C, so the compiled
> > program prints just "ok 2" and t/TEST is very unhappy.
> > The I_WANT_BEGIN_OUT ( or whatever ) works around that.
> > Hope it is clearer now.
>
> I think I know what's going on. Follow me here...
>
> You're compiling the test with B::C.
Yes
> You're running the compiled program.
Yes
> Code inside the BEGIN blocks has $^C set?? Or are they just not being
> run at all? Either of those are bugs. But there's a third
The code inside the begin blocks has $^C set ( as it should ), and they are being run
( as they should )
> possibility which I think is what's going on...
>
>
> If you were to take:
>
> BEGIN { print "foo" }
>
> compile it and run it, would you expect the output to be 'foo'? Or is
> the problem that you're getting 'foo' both during the compilation
> *and* when its run? As with this:
I'd expect the output of the compiled program to be nothing _normally_ ( perlcc
foo.pl ),
and "foo" _if I used the --testsuite switch when calling perlcc_
( perlcc --testsuite foo.pl ).
And in order to not have to introduce hacks in t/TEST, I'd like
that the compiled program resulting from
use Test::Simple tests => 12;
would print nothing normally, and 1..2 _if I passed the --testsuite
switch to perlcc_ .
> $ ./perl -Ilib -MO=Deparse -e 'BEGIN { print "foo\n" }'
> foo
> sub BEGIN {
> print "foo\n";
> }
> ;
> -e syntax OK
>
> if its that, you can do this:
>
> $ ./perl -Ilib -MO=-qq,Deparse -e 'BEGIN { print "foo\n" }'
> sub BEGIN {
> print "foo\n";
> }
> ;
>
> pass the -qq option to O.pm to make it both supress STDOUT and the -e
> syntax OK. Then it'll work as expected even with the $^C hack.
>
> $ ./perl -Ilib -MO=-qq,Deparse -e 'BEGIN { print "ok 1\n" } print "ok 2\n"' | ./perl
> ok 1
> ok 2
>
> $ ./perl -Ilib -MO=-qq,Deparse -e 'BEGIN { print "ok 1\n" unless $^C } print "ok
>2\n"' | ./perl
> ok 1
> ok 2
I am not completely sure I understood (sorry), but if that means taht you can remove
the $^C hack ( introduced for B::Deparse ) from Test::Builder, and pass the -qq to
O.pm to make Test::Builder and
B::Deparse play together, then that makes me very happy. Otherwise
I am afraid I didn't follow you...
Regards
Mattia