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. You're running the compiled program. 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 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: $ ./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 -- Michael G. Schwern <[EMAIL PROTECTED]> http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One Follow me to certain death! http://www.unamerican.com/